ElasticSearch--validate验证搜索语句是否合法或者存在语法错误

GET /accounts/person/_validate/query?explain
{
  "query":{
    "match": {
      "user": "lisi"
    }
  }
}
返回:
{
  "valid": true,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "explanations": [
    {
      "index": "accounts",
      "valid": true,
      "explanation": "+user:lisi #(#_type:person)"
    }
  ]
}

验证不通过 

GET /accounts/person/_validate/query?explain
{
  "query":{
    "math": {
      "user": "lisi"
    }
  }
}
返回:
{
  "valid": false,
  "error": "org.elasticsearch.common.ParsingException: no [query] registered for [math]"
}

关键字match写成了math

posted on 2020-05-31 19:36  luzhouxiaoshuai  阅读(295)  评论(0编辑  收藏  举报

导航