没有为[过滤]注册的[查询]

我有一个查询,我需要过滤出的结果。

This is my query

{
"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/en/elasticsearch/reference/current/query-dsl-filtered-query.html

67622 次浏览

在 ES 5.0中,filtered查询已经被废弃和删除。现在应该使用 bool/must/filter查询。

{
"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",

附注: 你正在看的参考页位于附录的“删除页”中,所以它不再是主要文档的一部分。