我有两个简单的请求。但它在一起不再起作用了。 我使用elasticsearch 1.4和drupal 7.
此查询有效,结果还可以:
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'match'=> [
'title' => [
'query' => "vivre et comprendre le cancer",
'operator' => "and"
]
]
]
]
];
第二个查询有效并且结果还可以:
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'filtered'=> [
'filter' => [
'bool' => [
'must' => [
'terms' => [
'field_support' => [105,106,1896,1897]
]
]
]
]
]
]
]
];
但是在一起我有一个错误:嵌套:ElasticsearchParseException [预期的字段名称但是得到了START_OBJECT \"过滤了"];
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'match'=> [
'title' => [
'query' => "vivre et comprendre le cancer",
'operator' => "and"
]
],
'filtered'=> [
'filter' => [
'bool' => [
'must' => [
'terms' => [
'field_support' => [105,106,1896,1897]
]
]
]
]
]
]
]
];
有人能帮助我吗?感谢
答案 0 :(得分:1)
您需要在match
一个
filtered > query
查询
$searchParams = [
'body' => [
"from"=> 0,
"size"=> 30000,
'query' => [
'filtered'=> [
'query' => [
'match'=> [
'title' => [
'query' => "vivre et comprendre le cancer",
'operator' => "and"
]
]
],
'filter' => [
'bool' => [
'must' => [
'terms' => [
'field_support' => [105,106,1896,1897]
]
]
]
]
]
]
]
];