2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-boosting-query]]
|
2015-06-03 19:59:22 -04:00
|
|
|
=== Boosting Query
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
The `boosting` query can be used to effectively demote results that
|
|
|
|
match a given query. Unlike the "NOT" clause in bool query, this still
|
|
|
|
selects documents that contain undesirable terms, but reduces their
|
|
|
|
overall score.
|
|
|
|
|
2018-11-15 21:45:32 -05:00
|
|
|
It accepts a `positive` query and a `negative` query.
|
|
|
|
Only documents that match the `positive` query will be included
|
|
|
|
in the results list, but documents that also match the `negative` query
|
|
|
|
will be downgraded by multiplying the original `_score` of the document
|
|
|
|
with the `negative_boost`.
|
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
2013-08-28 19:24:34 -04:00
|
|
|
{
|
2016-05-24 05:58:43 -04:00
|
|
|
"query": {
|
|
|
|
"boosting" : {
|
|
|
|
"positive" : {
|
|
|
|
"term" : {
|
|
|
|
"field1" : "value1"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"negative" : {
|
|
|
|
"term" : {
|
|
|
|
"field2" : "value2"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"negative_boost" : 0.2
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
// CONSOLE
|