Constant score query
Wraps a filter query and returns every matching document with a relevance score equal to the boost parameter value.
resp = client.search(
query={
"constant_score": {
"filter": {
"term": {
"user.id": "kimchy"
}
},
"boost": 1.2
}
},
)
print(resp) response = client.search(
body: {
query: {
constant_score: {
filter: {
term: {
'user.id' => 'kimchy'
}
},
boost: 1.2
}
}
}
)
puts response const response = await client.search({
query: {
constant_score: {
filter: {
term: {
"user.id": "kimchy",
},
},
boost: 1.2,
},
},
});
console.log(response); GET /_search
{
"query": {
"constant_score": {
"filter": {
"term": { "user.id": "kimchy" }
},
"boost": 1.2
}
}
} Top-level parameters for constant_score
-
filter -
(Required, query object) Filter query you wish to run. Any returned documents must match this query.
Filter queries do not calculate relevance scores. To speed up performance, Elasticsearch automatically caches frequently used filter queries.
-
boost - (Optional, float) Floating point number used as the constant relevance score for every document matching the
filterquery. Defaults to1.0.
© 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-constant-score-query.html