indices-query.asciidoc 1.1 KB

1234567891011121314151617181920212223242526272829
  1. [[java-query-dsl-indices-query]]
  2. ==== Indices Query
  3. See {ref}/query-dsl-indices-query.html[Indices Query]
  4. [source,java]
  5. --------------------------------------------------
  6. // Using another query when no match for the main one
  7. QueryBuilder qb = indicesQuery(
  8. termQuery("tag", "wow"), <1>
  9. "index1", "index2" <2>
  10. ).noMatchQuery(termQuery("tag", "kow")); <3>
  11. --------------------------------------------------
  12. <1> query to be executed on selected indices
  13. <2> selected indices
  14. <3> query to be executed on non matching indices
  15. [source,java]
  16. --------------------------------------------------
  17. // Using all (match all) or none (match no documents)
  18. QueryBuilder qb = indicesQuery(
  19. termQuery("tag", "wow"), <1>
  20. "index1", "index2" <2>
  21. ).noMatchQuery("all"); <3>
  22. --------------------------------------------------
  23. <1> query to be executed on selected indices
  24. <2> selected indices
  25. <3> `none` (to match no documents), and `all` (to match all documents). Defaults to `all`.