# Prefix 查询(前缀查询)

匹配包含具有指定前缀的项（**not analyzed**）的字段的文档。前缀查询对应**Lucene**的**PrefixQuery**。

以下匹配用户字段包含以 “ki” 开头的项的文档：

```
GET /_search
{ "query": {
    "prefix" : { "user" : "ki" }
  }
}
```

**boost**也可以和查询关联起来：

```
GET /_search
{ "query": {
    "prefix" : { "user" :  { "value" : "ki", "boost" : 2.0 } }
  }
}
```

或者和**prefix**语法配合（*5.0.0已经弃用*）：

```
GET /_search
{ "query": {
    "prefix" : { "user" :  { "prefix" : "ki", "boost" : 2.0 } }
  }
}
```

此多项查询允许您控制如何使用[rewrite](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-term-rewrite.html)参数重写。


---

# 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/354zhu-yu-ji-bie-cha-8be228-term-level-queries/prefix-cha-8be228-qian-zhui-cha-8be229.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.
