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

42 lines
1.1 KiB
Plaintext

[[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 <<query-filter-context, 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 <<query-filter-context, relevance scores>>. To
speed up performance, {es} automatically caches frequently used filter queries.
--
`boost`::
(Optional, float) Floating point number used as the constant
<<query-filter-context, relevance score>> for every document matching the
`filter` query. Defaults to `1.0`.