2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-indices-query]]
|
2015-06-03 19:59:22 -04:00
|
|
|
=== Indices Query
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-10-23 15:14:52 -04:00
|
|
|
The `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
|
2015-10-23 16:55:40 -04:00
|
|
|
on the list, the alternative `no_match_query` is executed.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2016-05-17 14:55:56 -04:00
|
|
|
"indices" : {
|
|
|
|
"indices" : ["index1", "index2"],
|
|
|
|
"query" : {
|
|
|
|
"term" : { "tag" : "wow" }
|
|
|
|
},
|
|
|
|
"no_match_query" : {
|
|
|
|
"term" : { "tag" : "kow" }
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2013-11-06 09:52:29 -05:00
|
|
|
You can use the `index` field to provide a single index.
|
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
`no_match_query` can also have "string" value of `none` (to match no
|
2013-11-06 09:52:29 -05:00
|
|
|
documents), and `all` (to match all). Defaults to `all`.
|
|
|
|
|
2013-11-14 09:53:13 -05:00
|
|
|
`query` is mandatory, as well as `indices` (or `index`).
|