2015-05-05 02:27:52 -04:00
|
|
|
[[query-dsl-constant-score-query]]
|
2015-06-03 19:59:22 -04:00
|
|
|
=== Constant Score Query
|
2015-05-05 02:27:52 -04:00
|
|
|
|
2019-06-21 12:03:19 -04:00
|
|
|
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.
|
2015-05-05 02:27:52 -04:00
|
|
|
|
|
|
|
[source,js]
|
2019-06-21 12:03:19 -04:00
|
|
|
----
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
2015-05-05 02:27:52 -04:00
|
|
|
{
|
2016-05-24 05:58:43 -04:00
|
|
|
"query": {
|
|
|
|
"constant_score" : {
|
|
|
|
"filter" : {
|
|
|
|
"term" : { "user" : "kimchy"}
|
|
|
|
},
|
|
|
|
"boost" : 1.2
|
|
|
|
}
|
2015-05-05 02:27:52 -04:00
|
|
|
}
|
|
|
|
}
|
2019-06-21 12:03:19 -04:00
|
|
|
----
|
2016-05-24 05:58:43 -04:00
|
|
|
// CONSOLE
|
2016-12-29 05:05:28 -05:00
|
|
|
|
2019-06-21 12:03:19 -04:00
|
|
|
[[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.
|