> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/elasticsearch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](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).

# 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)参数重写。
