elasticsearch 报错 :"no [query] registered for [missing]"

这个错误是在用elasticsearch查询时使用missing这个api报出的错误:
比如查询语句为:

GET ent_search/_search
{
  "_source": ["eid","ent_name","enttype_code"], 
  "query": {
    "constant_score": {
      "filter": {
        "missing": {
          "field": "enttype_code"
        }
      }
    }
  }
}

报错为:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "no [query] registered for [missing]",
        "line": 6,
        "col": 20
      }
    ],
    "type": "parsing_exception",
    "reason": "no [query] registered for [missing]",
    "line": 6,
    "col": 20
  },
  "status": 400
}

这是由于elasticsearch官方去掉了missing这个api,因为exists可以同时满足查询为空和非空两种需求,可参考:elasticsearch 处理null值

猜你喜欢

转载自blog.csdn.net/weixin_39800144/article/details/81208071