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 <<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`::
+
--
<<query-dsl-bool-query, Filter query>> you wish to run. Any returned documents
must match this query. Required.
Filter queries do not calculate <<query-filter-context, relevance scores>>. To
speed up performance, {es} automatically caches frequently used filter queries.
--
`boost`::
Floating point number used as the constant <<query-filter-context, relevance
score>> for every document matching the `filter` query. Default is `1.0`.
Optional.