OpenSearch/docs/reference/query-dsl/constant-score-query.asciidoc

42 lines
1.0 KiB
Plaintext
Raw Normal View History

[[query-dsl-constant-score-query]]
=== Constant score query
++++
<titleabbrev>Constant score</titleabbrev>
++++
Wraps a <<query-dsl-bool-query, filter query>> and returns every matching
document with a <<relevance-scores,relevance score>> equal to the `boost`
parameter value.
[source,js]
----
GET /_search
{
"query": {
"constant_score" : {
"filter" : {
"term" : { "user" : "kimchy"}
},
"boost" : 1.2
}
}
}
----
// CONSOLE
[[constant-score-top-level-params]]
==== Top-level parameters for `constant_score`
`filter`::
+
--
(Required, query object) <<query-dsl-bool-query, Filter query>> you wish to run.
Any returned documents must match this query.
Filter queries do not calculate <<relevance-scores,relevance scores>>. To
speed up performance, {es} automatically caches frequently used filter queries.
--
`boost`::
(Optional, float) Floating point number used as the constant
<<relevance-scores,relevance score>> for every document matching the
`filter` query. Defaults to `1.0`.