我尝试在php中构造一个具有不同attribut的查询: 以下代码工作:
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'filtered'=> [
'filter' => [
'bool' => [
'must' => [
'terms' => [
'field_support' => [105,106,1896,1897]
]
]
]
]
]
]
]
];
但是当我添加" term"它无法正常工作:
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'filtered'=> [
'filter' => [
'bool' => [
'must' => [
'terms' => [
'field_support' => [105,106,1896,1897]
],
'term' => [
'title' => ["le jeu de la dame"]
]
]
]
]
]
]
]
];
我不明白为什么它不起作用。 有人能帮助我吗?感谢
答案 0 :(得分:0)
您需要使用其他关联数组包围terms
和term
查询,如下所示:
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'filtered'=> [
'filter' => [
'bool' => [
'must' => [
[
'terms' => [
'field_support' => [105,106,1896,1897]
]
],
[
'term' => [
'title' => ["le jeu de la dame"]
]
]
]
]
]
]
]
]
];
<强>更新强>
变体match
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'filtered'=> [
'query' => [
'match' => [
'title' => ["le jeu de la dame"]
]
],
'filter' => [
'terms' => [
'field_support' => [105,106,1896,1897]
]
]
]
]
]
];