no [query] registered for [filtered]

使用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
                    ]
                }
            }
        }
    }
}



你可能感兴趣的:(elasticsearch)