# 短语前缀匹配查询(Match Phrase Prefix Query)

match\_phrase\_prefix与match\_phrase相同，除了它允许在文本的最后一个词上的前缀匹配

例如：

```
GET /_search
{
    "query": {
        "match_phrase_prefix" : {
            "message" : "quick brown f"
        }
    }
}
```

它接受与短语类型相同的参数。 此外，它还接受一个max\_expansions参数（默认值为50），它可以控制最后一项将被展开的前缀的数量。 强烈建议将其设置为可接受的值，以控制查询的执行时间

例如：

```
GET /_search
{
    "query": {
        "match_phrase_prefix" : {
            "message" : {
                "query" : "quick brown f",
                "max_expansions" : 10
            }
        }
    }
}
```

match\_phrase\_prefix查询是一个简单的自动填充。 非常容易使用，可以让你开始快速搜索你所需的类型，查询结果通常是正确的，但是有时可能是混乱的

> 建立一个短语字符串查询如： quick brown f。 此查询通过创建quick和brown短语查询工作（即术语quick必须存在，并且必须后跟术语brown）。 然后，它查看排序的术语字典以找到以f开头的前50个术语，并将这些术语添加到短语查询。
>
> 问题是前50个术语可能不包括术语狐狸，所以不会找到阶段快速棕色狐狸。 这通常不是问题，因为用户将继续键入更多的字母，直到他们正在寻找的单词出现


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xiaoxiami.gitbook.io/elasticsearch/ji-chu/35query-dsldslfang-shi-cha-8be229/quan-wen-sou-7d2228-full-text-search/duan-yu-qian-zhui-pi-pei-cha-8be228-match-phrase-prefix-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
