没有为 [已过滤] 注册 [查询] [英] no [query] registered for [filtered]

查看:35
本文介绍了没有为 [已过滤] 注册 [查询]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询需要过滤结果.

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 页面上过滤查询文档中给出的格式.https://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. https://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.

这篇关于没有为 [已过滤] 注册 [查询]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆