我有一个查询需要过滤结果.
I have a query which I need to filter out results.
这是我的查询
{ "query": { "filtered": { "query": { "multi_match": { "default_operator": "AND", "fields": [ "author", "title", "publisher", "year" ], "query": "George Orwell" } }, "filter": { "terms": { "year": [ 1980, 1981 ] } } } } }我收到一条错误消息,说没有为 [filtered] 注册的 [query].我显然有一个对过滤字段的查询.我正在遵循 elasticsearch 页面上过滤查询文档中给出的格式.www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html
I get an error saying no [query] registered for [filtered]. I clearly have a query for the filtered field. I am following the format given in the filtered query documentation on the elasticsearch page. www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html
推荐答案filtered 查询已在 ES 5.0 中弃用并删除.您现在应该使用 bool/must/filter 改为查询.
The filtered query has been deprecated and removed in ES 5.0. You should now use the bool/must/filter query instead.
{ "query": { "bool": { "must": { "multi_match": { "operator": "and", "fields": [ "author", "title", "publisher", "year" ], "query": "George Orwell" } }, "filter": { "terms": { "year": [ 1980, 1981 ] } } } } }以下是两个查询之间的区别:
Here are the differences between the two queries:
3,4c3,4 < "bool": { < "must": { --- > "filtered": { > "query": { 6c6 < "operator": "and", --- > "default_operator": "AND",PS:您正在查看的参考页面位于附录的已删除页面"中,因此它不再是主要文档的一部分.
PS: the reference page you're looking at is located in the "deleted pages" of the appendix, so it's not part of the main documentation anymore.
更多推荐
没有为 [已过滤] 注册 [查询]
发布评论