no [query] registered for [filtered] in es7 的解决方法

原文链接: https://blog.csdn.net/wslyk606/article/details/78896023

转自  https://blog.csdn.net/wslyk606/article/details/78896023

使用es查询条件为:

POST /_search

{
    "query": {
        "filtered": {
            "query": {
                "query_string": {
                    "query": "drama"
                }
            },
            "filter": {
                "term": { "year": 1962 }
            }
        }
    }
}

提示错误为:

{
   "error": {
      "root_cause": [
         {
            "type": "parsing_exception",
            "reason": "no [query] registered for [filtered]",
            "line": 3,
            "col": 21
         }
      ],
      "type": "parsing_exception",
      "reason": "no [query] registered for [filtered]",
      "line": 3,
      "col": 21
   },
   "status": 400
}

解决办法: 过滤查询已被弃用,并在ES 5.0中删除。现在应该使用bool / must / filter查询。

正确的应该为:

POST /_search
{
    "query": {
        "bool": {
            "must": {
                "multi_match": {
                    "fields": [
                        "title"
                    ],
                    "query": "kill"
                }
            },
            "filter": {
                "terms": {
                    "year": [
                        1962
                    ]
                }
            }
        }
    }
}
 ———————————————— 
版权声明:本文为CSDN博主「jack-life」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wslyk606/article/details/78896023

你可能感兴趣的:(no [query] registered for [filtered] in es7 的解决方法)