boosting-query.asciidoc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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,js]
  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. // CONSOLE
  35. [[boosting-top-level-params]]
  36. ==== Top-level parameters for `boosting`
  37. `positive`::
  38. (Required, query object) Query you wish to run. Any returned documents must
  39. match this query.
  40. `negative`::
  41. +
  42. --
  43. (Required, query object) Query used to decrease the <<relevance-scores,relevance
  44. score>> of matching documents.
  45. If a returned document matches the `positive` query and this query, the
  46. `boosting` query calculates the final <<relevance-scores,relevance score>> for
  47. the document as follows:
  48. . Take the original relevance score from the `positive` query.
  49. . Multiply the score by the `negative_boost` value.
  50. --
  51. `negative_boost`::
  52. (Required, float) Floating point number between `0` and `1.0` used to decrease
  53. the <<relevance-scores,relevance scores>> of documents matching the
  54. `negative` query.