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":"趙利文的CSDN博客內容最近更新挺頻繁"}'
結果:
{ “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
} ] }