multi-term-rewrite.asciidoc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. * When not set, or set to `constant_score_auto`, defaults to
  12. automatically choosing either `constant_score_boolean` or
  13. `constant_score_filter` based on query characteristics.
  14. * `scoring_boolean`: A rewrite method that first translates each term
  15. into a should clause in a boolean query, and keeps the scores as
  16. computed by the query. Note that typically such scores are meaningless
  17. to the user, and require non-trivial CPU to compute, so it's almost
  18. always better to use `constant_score_auto`. This rewrite method will hit
  19. too many clauses failure if it exceeds the boolean query limit (defaults
  20. to `1024`).
  21. * `constant_score_boolean`: Similar to `scoring_boolean` except scores
  22. are not computed. Instead, each matching document receives a constant
  23. score equal to the query's boost. This rewrite method will hit too many
  24. clauses failure if it exceeds the boolean query limit (defaults to
  25. `1024`).
  26. * `constant_score_filter`: A rewrite method that first creates a private
  27. Filter by visiting each term in sequence and marking all docs for that
  28. term. Matching documents are assigned a constant score equal to the
  29. query's boost.
  30. * `top_terms_N`: A rewrite method that first translates each term into
  31. should clause in boolean query, and keeps the scores as computed by the
  32. query. This rewrite method only uses the top scoring terms so it will
  33. not overflow boolean max clause count. The `N` controls the size of the
  34. top scoring terms to use.
  35. * `top_terms_boost_N`: A rewrite method that first translates each term
  36. into should clause in boolean query, but the scores are only computed as
  37. the boost. This rewrite method only uses the top scoring terms so it
  38. will not overflow the boolean max clause count. The `N` controls the
  39. size of the top scoring terms to use.