2015-05-05 02:27:52 -04:00
|
|
|
[[query-dsl-constant-score-query]]
|
2019-07-18 10:18:11 -04:00
|
|
|
=== Constant score query
|
|
|
|
++++
|
|
|
|
<titleabbrev>Constant score</titleabbrev>
|
|
|
|
++++
|
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`::
|
|
|
|
+
|
|
|
|
--
|
2019-07-31 14:18:22 -04:00
|
|
|
(Required, query object) <<query-dsl-bool-query, Filter query>> you wish to run.
|
|
|
|
Any returned documents must match this query.
|
2019-06-21 12:03:19 -04:00
|
|
|
|
|
|
|
Filter queries do not calculate <<query-filter-context, relevance scores>>. To
|
|
|
|
speed up performance, {es} automatically caches frequently used filter queries.
|
|
|
|
--
|
|
|
|
|
|
|
|
`boost`::
|
2019-07-31 14:18:22 -04:00
|
|
|
(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`.
|