dis-max-query.asciidoc 2.1 KB

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