indices-query.asciidoc 990 B

123456789101112131415161718192021222324252627282930
  1. [[query-dsl-indices-query]]
  2. === Indices Query
  3. The `indices` query is useful in cases where a search is executed across
  4. multiple indices. It allows to specify a list of index names and an inner
  5. query that is only executed for indices matching names on that list.
  6. For other indices that are searched, but that don't match entries
  7. on the list, the alternative `no_match_query` is executed.
  8. [source,js]
  9. --------------------------------------------------
  10. GET /_search
  11. {
  12. "query": {
  13. "indices" : {
  14. "indices" : ["index1", "index2"],
  15. "query" : { "term" : { "tag" : "wow" } },
  16. "no_match_query" : { "term" : { "tag" : "kow" } }
  17. }
  18. }
  19. }
  20. --------------------------------------------------
  21. // CONSOLE
  22. You can use the `index` field to provide a single index.
  23. `no_match_query` can also have "string" value of `none` (to match no
  24. documents), and `all` (to match all). Defaults to `all`.
  25. `query` is mandatory, as well as `indices` (or `index`).