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

原文地址:https://www.cnblogs.com/kebibuluan/p/13020914.html