# Fuzzy 查询(模糊查询)

> 从5.0.0开始已经标记为过时。
>
> 将在6.0中正式移除，使用**匹配查询**替代**模糊查询**。

模糊查询使用基于**Levenshtein 编辑距离**的相似性。

## 字符串字段

**模糊查询**生成在模糊性中指定的最大**编辑距离**内的所有可能的匹配项，然后检查项词典以找出实际存在于索引中的那些项。

这有一个简单示例：

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

或者可以增加一些高级设置：

```
GET /_search
{
    "query": {
        "fuzzy" : {
            "user" : {
                "value" :         "ki",
                    "boost" :         1.0,
                    "fuzziness" :     2,
                    "prefix_length" : 0,
                    "max_expansions": 100
            }
        }
    }
}
```

## 参数列表 <a href="#fuzzyquery-mo-hu-cha-xun-can-shu-lie-biao" id="fuzzyquery-mo-hu-cha-xun-can-shu-lie-biao"></a>

| 参数                | 说明                                                                                                                                                 |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| *fuzziness*       | 最大编辑距离，默认为**AUTO**。请参阅选项名为[**“Fuzzinessedit”**](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness)的部分。 |
| *prefix\_length*  | 不&#x4F1A;**“fuzzified”**&#x7684;初始字符数，这有助于减少必须检查的术语的量，默认值为0。                                                                                       |
| *max\_expansions* | **模糊查询**将扩展到的最大项数，默认值为50。                                                                                                                          |

> 如果 *prefix\_length* 设置为0，并且 *max\_expansions* 设置为一个高数字，这个查询可能非常重量级。它可能导致索引中的每个术语被检查！


---

# 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/fuzzy-cha-8be228-mo-hu-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.
