2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-boosting-query]]
|
2019-07-18 10:18:11 -04:00
|
|
|
=== Boosting query
|
|
|
|
++++
|
|
|
|
<titleabbrev>Boosting</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-06-28 08:35:20 -04:00
|
|
|
Returns documents matching a `positive` query while reducing the
|
2019-08-02 14:15:12 -04:00
|
|
|
<<relevance-scores,relevance score>> of documents that also match a
|
2019-06-28 08:35:20 -04:00
|
|
|
`negative` query.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-06-28 08:35:20 -04:00
|
|
|
You can use the `boosting` query to demote certain documents without
|
|
|
|
excluding them from the search results.
|
|
|
|
|
|
|
|
[[boosting-query-ex-request]]
|
|
|
|
==== Example request
|
2018-11-15 21:45:32 -05:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2019-06-28 08:35:20 -04:00
|
|
|
----
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
2013-08-28 19:24:34 -04:00
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"boosting": {
|
|
|
|
"positive": {
|
|
|
|
"term": {
|
|
|
|
"text": "apple"
|
2016-05-24 05:58:43 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
},
|
|
|
|
"negative": {
|
|
|
|
"term": {
|
|
|
|
"text": "pie tart fruit crumble tree"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"negative_boost": 0.5
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
2019-06-28 08:35:20 -04:00
|
|
|
----
|
|
|
|
|
|
|
|
[[boosting-top-level-params]]
|
|
|
|
==== Top-level parameters for `boosting`
|
|
|
|
|
2019-07-31 14:18:22 -04:00
|
|
|
`positive`::
|
|
|
|
(Required, query object) Query you wish to run. Any returned documents must
|
|
|
|
match this query.
|
2019-06-28 08:35:20 -04:00
|
|
|
|
2019-07-31 14:18:22 -04:00
|
|
|
`negative`::
|
2019-06-28 08:35:20 -04:00
|
|
|
+
|
|
|
|
--
|
2019-08-02 14:15:12 -04:00
|
|
|
(Required, query object) Query used to decrease the <<relevance-scores,relevance
|
|
|
|
score>> of matching documents.
|
2019-06-28 08:35:20 -04:00
|
|
|
|
|
|
|
If a returned document matches the `positive` query and this query, the
|
2019-08-02 14:15:12 -04:00
|
|
|
`boosting` query calculates the final <<relevance-scores,relevance score>> for
|
|
|
|
the document as follows:
|
2019-06-28 08:35:20 -04:00
|
|
|
|
|
|
|
. Take the original relevance score from the `positive` query.
|
|
|
|
. Multiply the score by the `negative_boost` value.
|
|
|
|
--
|
|
|
|
|
2019-07-31 14:18:22 -04:00
|
|
|
`negative_boost`::
|
|
|
|
(Required, float) Floating point number between `0` and `1.0` used to decrease
|
2019-08-02 14:15:12 -04:00
|
|
|
the <<relevance-scores,relevance scores>> of documents matching the
|
2019-07-31 14:18:22 -04:00
|
|
|
`negative` query.
|