| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | [[query-dsl-match-query-phrase-prefix]]=== Match Phrase Prefix QueryThe `match_phrase_prefix` is the same as `match_phrase`, except that itallows for prefix matches on the last term in the text. For example:[source,js]--------------------------------------------------GET /_search{    "query": {        "match_phrase_prefix" : {            "message" : "quick brown f"        }    }}--------------------------------------------------// CONSOLEIt accepts the same parameters as the phrase type. In addition, it alsoaccepts a `max_expansions` parameter (default `50`) that can control to howmany suffixes the last term will be expanded. It is highly recommended to setit to an acceptable value to control the execution time of the query. Forexample:[source,js]--------------------------------------------------GET /_search{    "query": {        "match_phrase_prefix" : {            "message" : {                "query" : "quick brown f",                "max_expansions" : 10            }        }    }}--------------------------------------------------// CONSOLE[IMPORTANT]===================================================The `match_phrase_prefix` query is a poor-man's autocomplete.  It is very easyto use, which lets you get started quickly with _search-as-you-type_ but itsresults, which usually are good enough,  can sometimes be confusing.Consider the query string `quick brown f`.  This query works by creating aphrase query out of `quick` and `brown` (i.e. the term `quick` must exist andmust be followed by the term `brown`).  Then it looks at the sorted termdictionary to find the first 50 terms that begin with `f`, andadds these terms to the phrase query.The problem is that the first 50 terms may not include the term `fox` so thephrase `quick brown fox` will not be found.  This usually isn't a problem asthe user will continue to type more letters until the word they are lookingfor appears.For better solutions for _search-as-you-type_ see the<<search-suggesters-completion,completion suggester>> and{defguide}/_index_time_search_as_you_type.html[Index-Time Search-as-You-Type].===================================================
 |