码迷,mamicode.com
首页 > 其他好文 > 详细

elasticsearch pinyin 拼音分词器

时间:2018-07-07 14:23:51      阅读:855      评论:0      收藏:0      [点我收藏+]

标签:fir   src   start   http   last   技术分享   first   let   分词器   

安装pinyin分词
地址:https://github.com/medcl/elasticsearch-analysis-pinyin

技术分享图片

技术分享图片

PUT py_test
{
  "index" : {
        "analysis" : {
            "analyzer" : {
                "pinyin_analyzer" : {
                    "tokenizer" : "my_pinyin",
                    "filter" : "word_delimiter"
                    }
            },
            "tokenizer" : {
                "my_pinyin" : {
                    "type" : "pinyin",
                    "first_letter" : "none",
                    "padding_char" : " "
                }
            }
        }
    }
}
GET py_test/_analyze
{
  "text":"刘德华",
  "analyzer":"pinyin_analyzer"
}

得到

{
  "tokens": [
    {
      "token": "liu",
      "start_offset": 0,
      "end_offset": 1,
      "type": "word",
      "position": 0
    },
    {
      "token": "ldh",
      "start_offset": 0,
      "end_offset": 3,
      "type": "word",
      "position": 0
    },
    {
      "token": "de",
      "start_offset": 1,
      "end_offset": 2,
      "type": "word",
      "position": 1
    },
    {
      "token": "hua",
      "start_offset": 2,
      "end_offset": 3,
      "type": "word",
      "position": 2
    }
  ]
}

elasticsearch pinyin 拼音分词器

标签:fir   src   start   http   last   技术分享   first   let   分词器   

原文地址:https://www.cnblogs.com/jiqing9006/p/9277104.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!