boosting-query.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. [[query-dsl-boosting-query]]
  2. === Boosting query
  3. ++++
  4. <titleabbrev>Boosting</titleabbrev>
  5. ++++
  6. Returns documents matching a `positive` query while reducing the
  7. <<relevance-scores,relevance score>> of documents that also match a
  8. `negative` query.
  9. You can use the `boosting` query to demote certain documents without
  10. excluding them from the search results.
  11. [[boosting-query-ex-request]]
  12. ==== Example request
  13. [source,console]
  14. ----
  15. GET /_search
  16. {
  17. "query": {
  18. "boosting": {
  19. "positive": {
  20. "term": {
  21. "text": "apple"
  22. }
  23. },
  24. "negative": {
  25. "term": {
  26. "text": "pie tart fruit crumble tree"
  27. }
  28. },
  29. "negative_boost": 0.5
  30. }
  31. }
  32. }
  33. ----
  34. [[boosting-top-level-params]]
  35. ==== Top-level parameters for `boosting`
  36. `positive`::
  37. (Required, query object) Query you wish to run. Any returned documents must
  38. match this query.
  39. `negative`::
  40. +
  41. --
  42. (Required, query object) Query used to decrease the <<relevance-scores,relevance
  43. score>> of matching documents.
  44. If a returned document matches the `positive` query and this query, the
  45. `boosting` query calculates the final <<relevance-scores,relevance score>> for
  46. the document as follows:
  47. . Take the original relevance score from the `positive` query.
  48. . Multiply the score by the `negative_boost` value.
  49. --
  50. `negative_boost`::
  51. (Required, float) Floating point number between `0` and `1.0` used to decrease
  52. the <<relevance-scores,relevance scores>> of documents matching the
  53. `negative` query.