1、打开找到对应的版本
https://github.com/medcl/elasticsearch-analysis-pinyin/releases
2、复制下载链接安装
例如:
我的elasticsearch是5.6.16
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v5.6.16/elasticsearch-analysis-pinyin-5.6.16.zip
3、重启ES!
4、分词测试
GET _analyze
{
"text": "学习",
"analyzer": "pinyin"
}
分词结果
{
"tokens": [
{
"token": "xue",
"start_offset": 0,
"end_offset": 1,
"type": "word",
"position": 0
},
{
"token": "xi",
"start_offset": 1,
"end_offset": 2,
"type": "word",
"position": 1
},
{
"token": "xx",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 1
}
]
}
自定义参数
参数 | 默认值 | 说明 |
---|---|---|
keep_first_letter | true | 刘德华>ldh |
keep_separate_first_letter | false | 刘德华>l,d,h |
limit_first_letter_length | 16 | set max length of the first_letter result |
keep_full_pinyin | true | 刘德华> [liu,de,hua] |
keep_joined_full_pinyin | false | 刘德华> [liudehua] |
keep_none_chinese | true | keep non chinese letter or number in result |
keep_none_chinese_together | true | true:DJ音乐家 -> DJ,yin,yue,jia; false:DJ音乐家 -> D,J,yin,yue,jia |
keep_none_chinese_in_first_letter | true | 刘德华AT2016->ldhat2016 |
keep_none_chinese_in_joined_full_pinyin | false | eg: 刘德华2016->liudehua2016 |
none_chinese_pinyin_tokenize | true | eg: liudehuaalibaba13zhuanghan -> liu,de,hua,a,li,ba,ba,13,zhuang,han |
keep_original | false | - |
lowercase | true | - |
trim_whitespace | true | - |
remove_duplicated_term | false | de的 > de |
ignore_pinyin_offset | true | - |