规范分词器

如果没有指定分词器,将应用规范分词器 standard 作为默认的分词器。

POST _analyze{  "analyzer": "standard",  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."}
[ the, 2, quick, brown, foxes, jumped, over, the, lazy, dog's, bone ]

规范分词器配置

  • max_token_length:最大标记长度。如果标记超过此长度,将以此长度作为距离,默认255。
  • stopwords:一个预约义的进行词(如 _english_)或一个蕴含进行词的数组。默认 _none_
  • stopwords_path:进行词的文件门路。

配置应用示例

PUT my-index-000001{  "settings": {    "analysis": {      "analyzer": {        "my_english_analyzer": {          "type": "standard",          "max_token_length": 5,          "stopwords": "_english_"        }      }    }  }}
POST my-index-000001/_analyze{  "analyzer": "my_english_analyzer",  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."}
[ 2, quick, brown, foxes, jumpe, d, over, lazy, dog's, bone ]

关键词分词器

keyword 分词器是一个“空转”分词器,也就是说会将输出的字符串作为单个标记原样返回。

POST _analyze{  "analyzer": "keyword",  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."}
[ The 2 QUICK Brown-Foxes jumped over the lazy dog's bone. ]