标准分词器

如果没有指定分词器,将使用标准分词器 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. ]

小伍
139 声望4 粉丝