禁用 Elasticsearch 搜索分析器

Disabling Elasticsearch search analyzer

Ps: 对于任何答案,如果您能指出答案所基于的 ES 官方文档,我将不胜感激。

搜索分析器在各种场景中发挥作用。

查询类型:- 分析了一些查询,有些则没有。像 match query uses the same analyzer on the fields which were defined in the index mapping, while queries like term query don't use any search time analyzer. Read elasticsearch match vs term query

这样分析的查询

也摘自官方 ES 文档

The match query is of type boolean. It means that the text provided is analyzed and the analysis process constructs a boolean query from the provided text.

字段类型:

Text fields 默认被分析,standard analyzer 是它们的默认分析器,因此如果你没有为索引映射中的文本字段定义分析器然后进行匹配查询,它将使用standard 分析器,但如果您使用 term 查询,则它不会使用搜索时间分析器。

keyword 字段然后它将使用关键字分析器,即 no-op 分析器,因此对于关键字字段的匹配查询它将使用关键字分析器但本质上就像不应用搜索时间分析器.

如果您使用的是匹配查询或任何其他使用搜索时间分析器的分析查询,那么您可以明确提及搜索时间分析器作为 keyword analyzer,正如我所解释的那样 no-op 分析器,因此生成令牌的过程将非常有效。