| 123456789101112131415161718192021222324252627282930313233343536373839404142 | [[query-dsl-multi-term-rewrite]]=== Multi Term Query RewriteMulti term queries, like<<query-dsl-wildcard-query,wildcard>> and<<query-dsl-prefix-query,prefix>> are calledmulti term queries and end up going through a process of rewrite. Thisalso happens on the<<query-dsl-query-string-query,query_string>>.All of those queries allow to control how they will get rewritten usingthe `rewrite` parameter:* When not set, or set to `constant_score_auto`, defaults toautomatically choosing either `constant_score_boolean` or`constant_score_filter` based on query characteristics.* `scoring_boolean`: A rewrite method that first translates each terminto a should clause in a boolean query, and keeps the scores ascomputed by the query. Note that typically such scores are meaninglessto the user, and require non-trivial CPU to compute, so it's almostalways better to use `constant_score_auto`. This rewrite method will hittoo many clauses failure if it exceeds the boolean query limit (defaultsto `1024`).* `constant_score_boolean`: Similar to `scoring_boolean` except scoresare not computed. Instead, each matching document receives a constantscore equal to the query's boost. This rewrite method will hit too manyclauses failure if it exceeds the boolean query limit (defaults to`1024`).* `constant_score_filter`: A rewrite method that first creates a privateFilter by visiting each term in sequence and marking all docs for thatterm. Matching documents are assigned a constant score equal to thequery's boost.* `top_terms_N`: A rewrite method that first translates each term intoshould clause in boolean query, and keeps the scores as computed by thequery. This rewrite method only uses the top scoring terms so it willnot overflow boolean max clause count. The `N` controls the size of thetop scoring terms to use.* `top_terms_boost_N`: A rewrite method that first translates each terminto should clause in boolean query, but the scores are only computed asthe boost. This rewrite method only uses the top scoring terms so itwill not overflow the boolean max clause count. The `N` controls thesize of the top scoring terms to use.
 |