我有一个查询,我需要过滤出结果。
这是我的查询
{ "query": { "filtered": { "query": { "multi_match": { "default_operator": "AND", "fields": [ "author", "title", "publisher", "year" ], "query": "George Orwell" } }, "filter": { "terms": { "year": [ 1980, 1981 ] } } } } }
我说错了no [query] registered for [filtered]。我显然对过滤字段有一个查询。我遵循的是Elasticsearch页面上经过过滤的查询文档中给出的格式。 https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/query-dsl- filtered- query.html
no [query] registered for [filtered]
该filtered查询已在ES 5.0中弃用并删除。您现在应该bool/must/filter改为使用查询。
filtered
bool/must/filter
{ "query": { "bool": { "must": { "multi_match": { "operator": "and", "fields": [ "author", "title", "publisher", "year" ], "query": "George Orwell" } }, "filter": { "terms": { "year": [ 1980, 1981 ] } } } } }
这是两个查询之间的区别:
3,4c3,4 < "bool": { < "must": { --- > "filtered": { > "query": { 6c6 < "operator": "and", --- > "default_operator": "AND",
PS:您正在查看的参考页面位于附录的“已删除页面”中,因此它不再是主要文档的一部分。