Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Rewrite compound queries overview #43877

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions docs/reference/query-dsl/compound-queries.asciidoc
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
[[compound-queries]]
== Compound queries

Compound queries wrap other compound or leaf queries, either to combine their
results and scores, to change their behaviour, or to switch from query to
filter context.
**Compound queries** wrap other queries so you can:

The queries in this group are:
* Combine multiple queries.

* Customize search results and <<relevance-scores,relevance scores>>.

* Run queries in a <<query-filter-context,filter context>> to improve
speed and performance.

[float]
[[compound-query-types]]
=== Compound query types

<<query-dsl-bool-query,`bool` query>>::
The default query for combining multiple leaf or compound query clauses, as
`must`, `should`, `must_not`, or `filter` clauses. The `must` and `should`
clauses have their scores combined -- the more matching clauses, the better --
while the `must_not` and `filter` clauses are executed in filter context.
Returns documents matching one or more wrapped queries using `and`, `or`, and
`not` logic.

<<query-dsl-boosting-query,`boosting` query>>::
Return documents which match a `positive` query, but reduce the score of
documents which also match a `negative` query.
Returns documents matching a `positive` query while reducing the relevance score
of documents that also match a `negative` query.

<<query-dsl-constant-score-query,`constant_score` query>>::
A query which wraps another query, but executes it in filter context. All
matching documents are given the same ``constant'' `_score`.
Wraps a <<query-dsl-bool-query, filter query>> and assigns every returned
document the same relevance score.

<<query-dsl-dis-max-query,`dis_max` query>>::
A query which accepts multiple queries, and returns any documents which match
any of the query clauses. While the `bool` query combines the scores from all
matching queries, the `dis_max` query uses the score of the single best-
matching query clause.
Returns documents matching one or more wrapped queries. If a returned document
matches more than one of these queries, the `dis_max` query assigns the document
the highest relevance score from any matching query, plus a tie breaking
increment for any additional matching subqueries.

<<query-dsl-function-score-query,`function_score` query>>::
Modify the scores returned by the main query with functions to take into
account factors like popularity, recency, distance, or custom algorithms
implemented with scripting.
Changes the relevance scores of documents returned by a wrapped query. You can
use the `function_score` query to incorporate factors like popularity, recency,
distance, or custom algorithms into your search results.


include::bool-query.asciidoc[]
Expand Down