Skip to content

Commit 8ac3c2d

Browse files
Adjustments to match Opster, readability (#119812) (#120031)
* Adjustments to match Opster, readability https://opster.com/guides/elasticsearch/search-apis/elasticsearch-bool-queries/ * Edits * Spacing --------- Co-authored-by: Kofi B <[email protected]>
1 parent d3a1d9b commit 8ac3c2d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/reference/query-dsl/bool-query.asciidoc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@ occurrence types are:
1313
|=======================================================================
1414
|Occur |Description
1515
|`must` |The clause (query) must appear in matching documents and will
16-
contribute to the score.
16+
contribute to the score. Each query defined under a `must` acts as a logical "AND", returning only documents that match _all_ the specified queries.
17+
18+
|`should` |The clause (query) should appear in the matching document. Each query defined under a `should` acts as a logical "OR", returning documents that match _any_ of the specified queries.
1719

1820
|`filter` |The clause (query) must appear in matching documents. However unlike
1921
`must` the score of the query will be ignored. Filter clauses are executed
2022
in <<query-filter-context,filter context>>, meaning that scoring is ignored
21-
and clauses are considered for caching.
22-
23-
|`should` |The clause (query) should appear in the matching document.
23+
and clauses are considered for caching. Each query defined under a `filter` acts as a logical "AND", returning only documents that match _all_ the specified queries.
2424

2525
|`must_not` |The clause (query) must not appear in the matching
2626
documents. Clauses are executed in <<query-filter-context,filter context>> meaning
2727
that scoring is ignored and clauses are considered for caching. Because scoring is
28-
ignored, a score of `0` for all documents is returned.
28+
ignored, a score of `0` for all documents is returned. Each query defined under a `must_not` acts as a logical "NOT", returning only documents that do not match any of the specified queries.
29+
2930
|=======================================================================
3031

32+
The `must` and `should` clauses function as logical AND, OR operators, contributing to the scoring of results. However, these results will not be cached for faster retrieval. In contrast, the `filter` and `must_not` clauses are used to include or exclude results without impacting the score, unless used within a `constant_score` query.
33+
3134
The `bool` query takes a _more-matches-is-better_ approach, so the score from
3235
each matching `must` or `should` clause will be added together to provide the
3336
final `_score` for each document.

0 commit comments

Comments
 (0)