WARNING: Version 2.4 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Indices Query
editIndices Query
editThe indices
query is useful in cases where a search is executed across
multiple indices. It allows to specify a list of index names and an inner
query that is only executed for indices matching names on that list.
For other indices that are searched, but that don’t match entries
on the list, the alternative no_match_query
is executed.
{ "indices" : { "indices" : ["index1", "index2"], "query" : { "term" : { "tag" : "wow" } }, "no_match_query" : { "term" : { "tag" : "kow" } } } }
You can use the index
field to provide a single index.
no_match_query
can also have "string" value of none
(to match no
documents), and all
(to match all). Defaults to all
.
query
is mandatory, as well as indices
(or index
).
The fields order is important: if the indices
are provided before query
or no_match_query
, the related queries get parsed only against the indices
that they are going to be executed on. This is useful to avoid parsing queries
when it is not necessary and prevent potential mapping errors.