2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-indices-query]]
|
|
|
|
=== Indices Query
|
|
|
|
|
|
|
|
The `indices` query can be used when executed across multiple indices,
|
|
|
|
allowing to have a query that executes only when executed on an index
|
|
|
|
that matches a specific list of indices, and another query that executes
|
|
|
|
when it is executed on an index that does not match the listed indices.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"indices" : {
|
|
|
|
"indices" : ["index1", "index2"],
|
|
|
|
"query" : {
|
|
|
|
"term" : { "tag" : "wow" }
|
|
|
|
},
|
|
|
|
"no_match_query" : {
|
|
|
|
"term" : { "tag" : "kow" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
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`.
|
|
|
|
|
|
|
|
`query` is mandatory. You must provide the indices.
|
|
|
|
It is forbidden to omit or to give `indices` or `index` multiple times,
|
|
|
|
or to give both.
|
|
|
|
|
|
|
|
Please note that the fields order is important: If the indices are
|
|
|
|
provided before `query` or `no_match_query`, the query parsing is
|
|
|
|
skipped altogether.
|
|
|
|
For instance, this feature is useful to prevent a query that runs
|
|
|
|
against multiple indices to fail because of a missing type.
|
|
|
|
See `has_child`, `has_parent`, `top_children` and `nested`.
|