ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Testing analyzers(测试分析器) analyze API是查看分析器生成词语的一个非常有用的工具。内置的分析器(或结合内置的分词器,词语过滤器和字符过滤器)可以在请求中指定内联: | `POST _analyze` `{` `"analyzer"``: ``"whitespace"``,` `"text"``:     ``"The quick brown fox."``}` `POST _analyze` `{` `"tokenizer"``: ``"standard"``,` `"filter"``:  [ ``"lowercase"``, ``"asciifolding"` `],` `"text"``:      ``"Is this déja vu?"``}` | ##### Positions and character offsets(位置和字符偏移) 从analyze API的输出可以看出,分析器不仅将单词转换为词语,还记录了每个词语(用于短语查询或近义词查询)的顺序或相对位置,以及原始文本中每个词语的起始和结束字符的偏移量(用于突出搜索片段)。 或者,在特定的索引上运行analyze API时,可以参考自定义分析器:   | `PUT my_index` `{` `"settings"``: {` `"analysis"``: {` `"analyzer"``: {` `"std_folded"``: {                       ``#1` `"type"``: ``"custom"``,` `"tokenizer"``: ``"standard"``,` `"filter"``: [` `"lowercase"``,` `"asciifolding"` `]` `}` `}` `}` `},` `"mappings"``: {` `"my_type"``: {` `"properties"``: {` `"my_text"``: {` `"type"``: ``"text"``,` `"analyzer"``: ``"std_folded"`            `#2` `}` `}` `}` `}}` `GET my_index``/_analyze` `{                       ``#3` `"analyzer"``: ``"std_folded"``,                   ``#4` `"text"``:     ``"Is this déjà vu?"``}` `GET my_index``/_analyze` `{                       ``#5` `"field"``: ``"my_text"``,                         ``#6` `"text"``:  ``"Is this déjà vu?"``}` | | 1 | 定义名为std_folded的自定义分析器。 | | 2 | 字段my_text使用std_folded分析器。 | | 3,5 | 要参考此分析器,analyze API必须指定索引名称。 | | 4 | 按名称查看分析器。 | | 6 | 请参阅字段my_text使用的分析器。 |