dis-max-query.asciidoc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. [[query-dsl-dis-max-query]]
  2. === Disjunction max query
  3. ++++
  4. <titleabbrev>Disjunction max</titleabbrev>
  5. ++++
  6. Returns documents matching one or more wrapped queries, called query clauses or
  7. clauses.
  8. If a returned document matches multiple query clauses, the `dis_max` query
  9. assigns the document the highest relevance score from any matching clause, plus
  10. a tie breaking increment for any additional matching subqueries.
  11. [[query-dsl-dis-max-query-ex-request]]
  12. ==== Example request
  13. [source,console]
  14. ----
  15. GET /_search
  16. {
  17. "query": {
  18. "dis_max": {
  19. "queries": [
  20. { "term": { "title": "Quick pets" } },
  21. { "term": { "body": "Quick pets" } }
  22. ],
  23. "tie_breaker": 0.7
  24. }
  25. }
  26. }
  27. ----
  28. [[query-dsl-dis-max-query-top-level-params]]
  29. ==== Top-level parameters for `dis_max`
  30. `queries`::
  31. (Required, array of query objects) Contains one or more query clauses. Returned
  32. documents **must match one or more** of these queries. If a document matches
  33. multiple queries, {es} uses the highest <<query-filter-context, relevance
  34. score>>.
  35. `tie_breaker`::
  36. +
  37. --
  38. (Optional, float) Floating point number between `0` and `1.0` used to increase
  39. the <<relevance-scores,relevance scores>> of documents matching multiple
  40. query clauses. Defaults to `0.0`.
  41. You can use the `tie_breaker` value to assign higher relevance scores to
  42. documents that contain the same term in multiple fields than documents that
  43. contain this term in only the best of those multiple fields, without confusing
  44. this with the better case of two different terms in the multiple fields.
  45. If a document matches multiple clauses, the `dis_max` query calculates the
  46. relevance score for the document as follows:
  47. . Take the relevance score from a matching clause with the highest score.
  48. . Multiply the score from any other matching clauses by the `tie_breaker` value.
  49. . Add the highest score to the multiplied scores.
  50. If the `tie_breaker` value is greater than `0.0`, all matching clauses count,
  51. but the clause with the highest score counts most.
  52. --