<commit_before>[[query-dsl-match-query-phrase-prefix]]
=== Match Phrase Prefix Query

The `match_phrase_prefix` is the same as `match_phrase`, except that it
allows for prefix matches on the last term in the text. For example:

[source,js]
--------------------------------------------------
GET /_search
{
    "query": {
        "match_phrase_prefix" : {
            "message" : "quick brown f"
        }
    }
}
--------------------------------------------------
// CONSOLE

It accepts the same parameters as the phrase type. In addition, it also
accepts a `max_expansions` parameter (default `50`) that can control to how
many prefixes the last term will be expanded. It is highly recommended to set
it to an acceptable value to control the execution time of the query. For
example:

[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 easy
to use, which let's you get started quickly with _search-as-you-type_ but it's
results, which usually are good enough,  can sometimes be confusing.

Consider the query string `quick brown f`.  This query works by creating a
phrase query out of `quick` and `brown` (i.e. the term `quick` must exist and
must be followed by the term `brown`).  Then it looks at the sorted term
dictionary to find the first 50 terms that begin with `f`, and
adds these terms to the phrase query.

The problem is that the first 50 terms may not include the term `fox` so the
phase `quick brown fox` will not be found.  This usually isn't a problem as
the user will continue to type more letters until the word they are looking
for 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].

===================================================<commit_msg>Correct some spelling in match-phrase-prefix docs (#24956)<commit_after>[[query-dsl-match-query-phrase-prefix]]
=== Match Phrase Prefix Query

The `match_phrase_prefix` is the same as `match_phrase`, except that it
allows for prefix matches on the last term in the text. For example:

[source,js]
--------------------------------------------------
GET /_search
{
    "query": {
        "match_phrase_prefix" : {
            "message" : "quick brown f"
        }
    }
}
--------------------------------------------------
// CONSOLE

It accepts the same parameters as the phrase type. In addition, it also
accepts a `max_expansions` parameter (default `50`) that can control to how
many suffixes the last term will be expanded. It is highly recommended to set
it to an acceptable value to control the execution time of the query. For
example:

[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 easy
to use, which lets you get started quickly with _search-as-you-type_ but its
results, which usually are good enough,  can sometimes be confusing.

Consider the query string `quick brown f`.  This query works by creating a
phrase query out of `quick` and `brown` (i.e. the term `quick` must exist and
must be followed by the term `brown`).  Then it looks at the sorted term
dictionary to find the first 50 terms that begin with `f`, and
adds these terms to the phrase query.

The problem is that the first 50 terms may not include the term `fox` so the
phrase `quick brown fox` will not be found.  This usually isn't a problem as
the user will continue to type more letters until the word they are looking
for 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].

===================================================
{'fraction_non_alphanumeric': 0.20190602836879432, 'fraction_numerical': 0.004654255319148936, 'mean_word_length': 2.4215314632297193, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1789669', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1150, 'n_words': 518}