boosting-query.asciidoc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. [[query-dsl-boosting-query]]
  2. === Boosting Query
  3. The `boosting` query can be used to effectively demote results that
  4. match a given query. Unlike the "NOT" clause in bool query, this still
  5. selects documents that contain undesirable terms, but reduces their
  6. overall score.
  7. It accepts a `positive` query and a `negative` query.
  8. Only documents that match the `positive` query will be included
  9. in the results list, but documents that also match the `negative` query
  10. will be downgraded by multiplying the original `_score` of the document
  11. with the `negative_boost`.
  12. [source,js]
  13. --------------------------------------------------
  14. GET /_search
  15. {
  16. "query": {
  17. "boosting" : {
  18. "positive" : {
  19. "term" : {
  20. "field1" : "value1"
  21. }
  22. },
  23. "negative" : {
  24. "term" : {
  25. "field2" : "value2"
  26. }
  27. },
  28. "negative_boost" : 0.2
  29. }
  30. }
  31. }
  32. --------------------------------------------------
  33. // CONSOLE