GET /test_index/test_type/_validate/query?explain { "query": { "math": { "test_field": "test" } } }
這邊math拼寫錯誤,相對應的返回:api
{ "valid": false, "error": "org.elasticsearch.common.ParsingException: no [query] registered for [math]" }
字段拼寫錯誤:elasticsearch
GET /test_index/test_type/_validate/query?explain { "query": { "match": { "test_field": "test" } } } { "valid": true, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "explanations": [ { "index": "test_index", "valid": true, "explanation": "+test_field:test #(#_type:test_type)" } ] }
通常用在那種特別複雜龐大的搜索下,好比你一會兒寫了上百行的搜索,這個時候能夠先用validate api去驗證一下,搜索是否合法spa