| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | [[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:* `constant_score` (default): A rewrite method that performs like`constant_score_boolean` when there are few matching terms and otherwisevisits all matching terms in sequence and marks documents for that term.Matching documents are assigned a constant score equal to the query'sboost.* `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`).* `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.* `top_terms_blended_freqs_N`: A rewrite method that first translates eachterm into should clause in boolean query, but all term queries compute scoresas if they had the same frequency. In practice the frequency which is usedis the maximum frequency of all matching terms. This rewrite method only usesthe top scoring terms so it will not overflow boolean max clause count. The`N` controls the size of the top scoring terms to use.
 |