2013-08-29 01:24:34 +02:00
|
|
|
[[query-dsl-indices-query]]
|
2015-06-04 01:59:22 +02:00
|
|
|
=== Indices Query
|
2013-08-29 01:24:34 +02:00
|
|
|
|
2016-08-02 17:35:31 -04:00
|
|
|
deprecated[5.0.0, Search on the '_index' field instead]
|
|
|
|
|
2015-10-23 21:14:52 +02: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 22:55:40 +02:00
|
|
|
on the list, the alternative `no_match_query` is executed.
|
2013-08-29 01:24:34 +02:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-05-24 11:58:43 +02:00
|
|
|
GET /_search
|
2013-08-29 01:24:34 +02:00
|
|
|
{
|
2016-05-24 11:58:43 +02:00
|
|
|
"query": {
|
|
|
|
"indices" : {
|
|
|
|
"indices" : ["index1", "index2"],
|
|
|
|
"query" : { "term" : { "tag" : "wow" } },
|
|
|
|
"no_match_query" : { "term" : { "tag" : "kow" } }
|
2013-08-29 01:24:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-08-02 17:35:31 -04:00
|
|
|
// CONSOLE
|
|
|
|
// TEST[warning:indices query is deprecated. Instead search on the '_index' field]
|
2013-08-29 01:24:34 +02:00
|
|
|
|
2013-11-06 15:52:29 +01:00
|
|
|
You can use the `index` field to provide a single index.
|
|
|
|
|
2013-08-29 01:24:34 +02:00
|
|
|
`no_match_query` can also have "string" value of `none` (to match no
|
2013-11-06 15:52:29 +01:00
|
|
|
documents), and `all` (to match all). Defaults to `all`.
|
|
|
|
|
2013-11-14 15:53:13 +01:00
|
|
|
`query` is mandatory, as well as `indices` (or `index`).
|