1. 在linux系统中,首先将将IK分词器下载下来
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.1/elasticsearch-analysis-ik-7.7.1.zip
将文件加压到Elasticsear安装目录的plugin/analysis-ik下
unzip elasticsearch-analysis-ik-7.7.1.zip -d /usr/share/elasticsearch/plugins/analysis-ik
2. 重启Elasticsearch服务
systemctl restart elsaticsearch.service
3. 验证IK分词器
curl -H 'Content-Type: application/json' -XGET 'localhost:9200/_analyze?pretty' -d '{"analyzer":"ik_max_word","text":"赵利文的优快云博客内容最近更新挺频繁"}'
结果:
{ “tokens” : [
{
“token” : “赵”,
“start_offset” : 0,
“end_offset” : 1,
“type” : “CN_CHAR”,
“position” : 0
},
{
“token” : “利”,
“start_offset” : 1,
“end_offset” : 2,
“type” : “CN_CHAR”,
“position” : 1
},
{
“token” : “文”,
“start_offset” : 2,
“end_offset” : 3,
“type” : “CN_CHAR”,
“position” : 2
},
{
“token” : “的”,
“start_offset” : 3,
“end_offset” : 4,
“type” : “CN_CHAR”,
“position” : 3
},
{
“token” : “csdn”,
“start_offset” : 4,
“end_offset” : 8,
“type” : “ENGLISH”,
“position” : 4
},
{
“token” : “博客”,
“start_offset” : 8,
“end_offset” : 10,
“type” : “CN_WORD”,
“position” : 5
},
{
“token” : “内容”,
“start_offset” : 10,
“end_offset” : 12,
“type” : “CN_WORD”,
“position” : 6
},
{
“token” : “最近”,
“start_offset” : 12,
“end_offset” : 14,
“type” : “CN_WORD”,
“position” : 7
},
{
“token” : “更新”,
“start_offset” : 14,
“end_offset” : 16,
“type” : “CN_WORD”,
“position” : 8
},
{
“token” : “挺”,
“start_offset” : 16,
“end_offset” : 17,
“type” : “CN_CHAR”,
“position” : 9
},
{
“token” : “频繁”,
“start_offset” : 17,
“end_offset” : 19,
“type” : “CN_WORD”,
“position” : 10
} ] }