OpenSearch/docs/reference/query-dsl/boosting-query.asciidoc

63 lines
1.6 KiB
Plaintext
Raw Normal View History

[[query-dsl-boosting-query]]
=== Boosting query
++++
<titleabbrev>Boosting</titleabbrev>
++++
2019-06-28 08:35:20 -04:00
Returns documents matching a `positive` query while reducing the
<<query-filter-context, relevance score>> of documents that also match a
`negative` query.
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
[source,js]
2019-06-28 08:35:20 -04:00
----
GET /_search
{
"query": {
"boosting" : {
"positive" : {
"term" : {
2019-06-28 08:35:20 -04:00
"text" : "apple"
}
},
"negative" : {
"term" : {
2019-06-28 08:35:20 -04:00
"text" : "pie tart fruit crumble tree"
}
},
2019-06-28 08:35:20 -04:00
"negative_boost" : 0.5
}
}
}
2019-06-28 08:35:20 -04:00
----
// CONSOLE
2019-06-28 08:35:20 -04:00
[[boosting-top-level-params]]
==== Top-level parameters for `boosting`
`positive` (Required)::
Query you wish to run. Any returned documents must match this query.
`negative` (Required)::
+
--
Query used to decrease the <<query-filter-context, relevance score>> of matching
documents.
If a returned document matches the `positive` query and this query, the
`boosting` query calculates the final <<query-filter-context, relevance score>>
for the document as follows:
. Take the original relevance score from the `positive` query.
. Multiply the score by the `negative_boost` value.
--
`negative_boost` (Required)::
Floating point number between `0` and `1.0` used to decrease the
<<query-filter-context, relevance scores>> of documents matching the `negative`
query.