1
0

dis-max-query.asciidoc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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,js]
  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. // CONSOLE
  31. [[query-dsl-dis-max-query-top-level-params]]
  32. ==== Top-level parameters for `dis_max`
  33. `queries`::
  34. (Required, array of query objects) Contains one or more query clauses. Returned
  35. documents **must match one or more** of these queries. If a document matches
  36. multiple queries, {es} uses the highest <<query-filter-context, relevance
  37. score>>.
  38. `tie_breaker`::
  39. +
  40. --
  41. (Optional, float) Floating point number between `0` and `1.0` used to increase
  42. the <<relevance-scores,relevance scores>> of documents matching multiple
  43. query clauses. Defaults to `0.0`.
  44. You can use the `tie_breaker` value to assign higher relevance scores to
  45. documents that contain the same term in multiple fields than documents that
  46. contain this term in only the best of those multiple fields, without confusing
  47. this with the better case of two different terms in the multiple fields.
  48. If a document matches multiple clauses, the `dis_max` query calculates the
  49. relevance score for the document as follows:
  50. . Take the relevance score from a matching clause with the highest score.
  51. . Multiply the score from any other matching clauses by the `tie_breaker` value.
  52. . Add the highest score to the multiplied scores.
  53. If the `tie_breaker` value is greater than `0.0`, all matching clauses count,
  54. but the clause with the highest score counts most.
  55. --