multi-term-rewrite.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. [[query-dsl-multi-term-rewrite]]
  2. == Multi Term Query Rewrite
  3. Multi term queries, like
  4. <<query-dsl-wildcard-query,wildcard>> and
  5. <<query-dsl-prefix-query,prefix>> are called
  6. multi term queries and end up going through a process of rewrite. This
  7. also happens on the
  8. <<query-dsl-query-string-query,query_string>>.
  9. All of those queries allow to control how they will get rewritten using
  10. the `rewrite` parameter:
  11. * `constant_score` (default): A rewrite method that performs like
  12. `constant_score_boolean` when there are few matching terms and otherwise
  13. visits all matching terms in sequence and marks documents for that term.
  14. Matching documents are assigned a constant score equal to the query's
  15. boost.
  16. * `scoring_boolean`: A rewrite method that first translates each term
  17. into a should clause in a boolean query, and keeps the scores as
  18. computed by the query. Note that typically such scores are meaningless
  19. to the user, and require non-trivial CPU to compute, so it's almost
  20. always better to use `constant_score_auto`. This rewrite method will hit
  21. too many clauses failure if it exceeds the boolean query limit (defaults
  22. to `1024`).
  23. * `constant_score_boolean`: Similar to `scoring_boolean` except scores
  24. are not computed. Instead, each matching document receives a constant
  25. score equal to the query's boost. This rewrite method will hit too many
  26. clauses failure if it exceeds the boolean query limit (defaults to
  27. `1024`).
  28. * `top_terms_N`: A rewrite method that first translates each term into
  29. should clause in boolean query, and keeps the scores as computed by the
  30. query. This rewrite method only uses the top scoring terms so it will
  31. not overflow boolean max clause count. The `N` controls the size of the
  32. top scoring terms to use.
  33. * `top_terms_boost_N`: A rewrite method that first translates each term
  34. into should clause in boolean query, but the scores are only computed as
  35. the boost. This rewrite method only uses the top scoring terms so it
  36. will not overflow the boolean max clause count. The `N` controls the
  37. size of the top scoring terms to use.
  38. * `top_terms_blended_freqs_N`: A rewrite method that first translates each
  39. term into should clause in boolean query, but all term queries compute scores
  40. as if they had the same frequency. In practice the frequency which is used
  41. is the maximum frequency of all matching terms. This rewrite method only uses
  42. the top scoring terms so it will not overflow boolean max clause count. The
  43. `N` controls the size of the top scoring terms to use.