Disjunction max query
Returns documents matching one or more wrapped queries, called query clauses or clauses.
If a returned document matches multiple query clauses, the dis_max query assigns the document the highest relevance score from any matching clause, plus a tie breaking increment for any additional matching subqueries.
Example request
resp = client.search(
query={
"dis_max": {
"queries": [
{
"term": {
"title": "Quick pets"
}
},
{
"term": {
"body": "Quick pets"
}
}
],
"tie_breaker": 0.7
}
},
)
print(resp) response = client.search(
body: {
query: {
dis_max: {
queries: [
{
term: {
title: 'Quick pets'
}
},
{
term: {
body: 'Quick pets'
}
}
],
tie_breaker: 0.7
}
}
}
)
puts response const response = await client.search({
query: {
dis_max: {
queries: [
{
term: {
title: "Quick pets",
},
},
{
term: {
body: "Quick pets",
},
},
],
tie_breaker: 0.7,
},
},
});
console.log(response); GET /_search
{
"query": {
"dis_max": {
"queries": [
{ "term": { "title": "Quick pets" } },
{ "term": { "body": "Quick pets" } }
],
"tie_breaker": 0.7
}
}
} Top-level parameters for dis_max
-
queries - (Required, array of query objects) Contains one or more query clauses. Returned documents must match one or more of these queries. If a document matches multiple queries, Elasticsearch uses the highest relevance score.
-
tie_breaker -
(Optional, float) Floating point number between
0and1.0used to increase the relevance scores of documents matching multiple query clauses. Defaults to0.0.You can use the
tie_breakervalue to assign higher relevance scores to documents that contain the same term in multiple fields than documents that contain this term in only the best of those multiple fields, without confusing this with the better case of two different terms in the multiple fields.If a document matches multiple clauses, the
dis_maxquery calculates the relevance score for the document as follows:- Take the relevance score from a matching clause with the highest score.
- Multiply the score from any other matching clauses by the
tie_breakervalue. - Add the highest score to the multiplied scores.
If the
tie_breakervalue is greater than0.0, all matching clauses count, but the clause with the highest score counts most.
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/query-dsl-dis-max-query.html