Elasticsearch _validate API fails queries that _search API allows -
i’m trying use _validate api , rejects invalid queries exact body submitted works when sent _search api. _validate request body need different in way?
for “explain” result things “no query registered [fields]". removing return fields list, complains filter.
here example:
curl -s -xget 'http://localhost:9200/4af9aae4-7ec1-458d-8c50-692ddb0f2c6d/msg,file,file-info/_validate/query?explain=true' -d '{"fields":["id"],"filter":{"not":{"and":[{"numeric_range":{"msg-size":{"gte":1000}}},{"query":{"prefix":{"content-type.verbatim":"application/"}}}]}}}' | python -mjson.tool { "_shards": { "failed": 0, "successful": 1, "total": 1 }, "explanations": [ { "error": "org.elasticsearch.index.query.queryparsingexception: [4af9aae4-7ec1-458d-8c50-692ddb0f2c6d-0] request not support [fields]", "index": "4af9aae4-7ec1-458d-8c50-692ddb0f2c6d-0", "valid": false } ], "valid": false }
removing fields, reports query not support filter
curl -s -xget 'http://localhost:9200/4af9aae4-7ec1-458d-8c50-692ddb0f2c6d/msg,file,file-info/_validate/query?explain=true' -d '{"filter":{"not":{"and":[{"numeric_range":{"msg-size":{"gte":1000}}},{"query":{"prefix":{"content-type.verbatim":"application/"}}}]}}}' | python -mjson.tool { "_shards": { "failed": 0, "successful": 1, "total": 1 }, "explanations": [ { "error": "org.elasticsearch.index.query.queryparsingexception: [4af9aae4-7ec1-458d-8c50-692ddb0f2c6d-0] request not support [filter]", "index": "4af9aae4-7ec1-458d-8c50-692ddb0f2c6d-0", "valid": false } ], "valid": false }
some queries work validate api, it's not across-the-board failure.
curl -s -xget 'http://localhost:9200/4af9aae4-7ec1-458d-8c50-692ddb0f2c6d/msg,file,file-info/_validate/query?explain=true' -d '{"query": { "match": { "file-name": "please read: not important" }}}' | python -mjson.tool { "_shards": { "failed": 0, "successful": 1, "total": 1 }, "explanations": [ { "explanation": "filtered(file-name:please read: not important)->cache(_type:file _type:file-info _type:msg)", "index": "4af9aae4-7ec1-458d-8c50-692ddb0f2c6d-0", "valid": true } ], "valid": true }
my understanding _validate runs same syntax checks etc when actually execute query, not sure going on.
other details:
elasticsearch v 1.2.1 ubuntu linux precise 64
you need wrap query in query key use _validate endpoint - that's why last example working first 2 not.
note
the query being sent in body must nested in query key, same search api works [1.0.0.rc1] added in 1.0.0.rc1. query top-level object..
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-validate.html
Comments
Post a Comment