boosting-query.asciidoc 1.6 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. <<query-filter-context, 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` (Required)::
  38. Query you wish to run. Any returned documents must match this query.
  39. `negative` (Required)::
  40. +
  41. --
  42. Query used to decrease the <<query-filter-context, relevance score>> of matching
  43. documents.
  44. If a returned document matches the `positive` query and this query, the
  45. `boosting` query calculates the final <<query-filter-context, relevance score>>
  46. for 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` (Required)::
  51. Floating point number between `0` and `1.0` used to decrease the
  52. <<query-filter-context, relevance scores>> of documents matching the `negative`
  53. query.