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
|
2019-08-02 14:15:12 -04:00
|
|
|
document with a <<relevance-scores,relevance score>> equal to the `boost`
|
2019-06-21 12:03:19 -04:00
|
|
|
parameter value.
|
2015-05-05 02:27:52 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
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
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"constant_score": {
|
|
|
|
"filter": {
|
|
|
|
"term": { "user": "kimchy" }
|
|
|
|
},
|
|
|
|
"boost": 1.2
|
2015-05-05 02:27:52 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2015-05-05 02:27:52 -04:00
|
|
|
}
|
2019-06-21 12:03:19 -04:00
|
|
|
----
|
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
|
|
|
|
2019-08-02 14:15:12 -04:00
|
|
|
Filter queries do not calculate <<relevance-scores,relevance scores>>. To
|
2019-06-21 12:03:19 -04:00
|
|
|
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
|
2019-08-02 14:15:12 -04:00
|
|
|
<<relevance-scores,relevance score>> for every document matching the
|
2019-07-31 14:18:22 -04:00
|
|
|
`filter` query. Defaults to `1.0`.
|