当前位置: 首页 > 面试题库 >

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

杨波娃
2023-03-14
问题内容

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

这是我的查询

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


问题答案:

filtered查询已在ES
5.0中弃用并删除。您现在应该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:您正在查看的参考页面位于附录的“已删除页面”中,因此它不再是主要文档的一部分。



 类似资料:
  • 问题内容: 我正在尝试对我的ElasticSearch Server进行此查询。 基本上,我希望检索名称中与“ network”匹配的所有产品,但仅过滤与或匹配的产品。当我执行此查询时,我收到此错误信息。 我想这里的关键是,但无法理解这里出了什么问题。 问题答案: 是查询,而不是过滤器。 在这种情况下,您可能需要-filter。

  • 我有一个查询,我需要过滤出结果。 这是我的查询 我得到一个错误,说注册[query]。我显然有一个筛选字段的查询。我遵循elasticsearch页面上筛选的查询文档中给出的格式。https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html

  • 我试图从弹性搜索获取记录,我得到这个错误如下 我的Java代码如下 请让我知道,如果我错过了一些东西,而试图索引,我是新的弹性搜索。 同样,如果我想在我的查询中包括一个以上的条件,如下面所示 下面是上述查询的结果,它工作正常 我如何与上面的geoboundingbox查询相结合?我需要将其添加为过滤器吗? 更新:依赖关系 提前谢谢Rakesh

  • 有人能帮我解决这个问题吗?我收到一个错误返回:“没有为[注册查询或]”我是否结构错误?它应该过滤区域为530且开始为空白或区域为530且开始为“06192013”的所有结果,然后在此基础上使用其他过滤器提升文档。

  • void register_prefilter(mixed function) Use this to dynamically register prefilters to run templates through before they are compiled. See template prefilters for more information on how to setup a pr

  • void register_postfilter(mixed function) Use this to dynamically register postfilters to run templates through after they are compiled. See template postfilters for more information on how to setup a