The IDs query and filter allow matching documents by their IDs.
For executing IDS queries/filters, we need to perform the following steps:
The
ids
query for fetching IDs1
,2
,3
of thetest-type
type is in the following form:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "ids" : { "type" : "test-type", "values" : ["1", "2", "3"] } } } }'
The same query can be converted in a filter query similar to the following one:
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "filtered": { "filter": { "ids" : { "type" : "test-type", "values" : ["1", "2", "3"] } }, "query": { "match_all": {} } } } }'