Jieba Search 分词器

Jieba Search 分词器 #

jieba_search 分词器是 analysis-jieba 插件 提供的搜索模式分词器。它在精确分词的基础上对长词不做额外切分,适合搜索时使用。

前提条件 #

bin/easysearch-plugin install analysis-jieba

与 jieba_index 的对比 #

分词器模式以"中华人民共和国"为例适用场景
jieba_search精确模式中华人民共和国搜索时
jieba_index索引模式中华、华人、人民、共和、共和国、中华人民共和国索引时

使用示例 #

索引/搜索搭配 #

PUT my-jieba-index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "jieba_idx": {
          "type": "custom",
          "tokenizer": "jieba_index"
        },
        "jieba_srch": {
          "type": "custom",
          "tokenizer": "jieba_search"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "jieba_idx",
        "search_analyzer": "jieba_srch"
      }
    }
  }
}

测试分词 #

GET /_analyze
{
  "tokenizer": "jieba_search",
  "text": "中华人民共和国国歌"
}

相关链接 #