bool-query.asciidoc 624 B

12345678910111213141516171819
  1. [[java-query-dsl-bool-query]]
  2. ==== Bool Query
  3. See {ref}/query-dsl-bool-query.html[Bool Query]
  4. [source,java]
  5. --------------------------------------------------
  6. QueryBuilder qb = boolQuery()
  7. .must(termQuery("content", "test1")) <1>
  8. .must(termQuery("content", "test4")) <1>
  9. .mustNot(termQuery("content", "test2")) <2>
  10. .should(termQuery("content", "test3")) <3>
  11. .filter(termQuery("content", "test5")); <4>
  12. --------------------------------------------------
  13. <1> must query
  14. <2> must not query
  15. <3> should query
  16. <4> a query that must appear in the matching documents but doesn't contribute to scoring.