boosting-query.asciidoc 1.5 KB

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