Elasticsearch安裝ik分詞器(二)

一、先測試是否安裝了ik分詞器

先測試是否安裝了ik分詞器:
http://10.1.2.206:9200/_analyze?analyzer=standard&pretty=true&text=中華人民共和國

沒有安裝則如下:
tokens  
0   
token   "中"
start_offset    0
end_offset  1
type    "<IDEOGRAPHIC>"
position    1
1   
token   "華"
start_offset    1
end_offset  2
type    "<IDEOGRAPHIC>"
position    2
2   
token   "人"
start_offset    2
end_offset  3
type    "<IDEOGRAPHIC>"
position    3
3   
token   "民"
start_offset    3
end_offset  4
type    "<IDEOGRAPHIC>"
position    4
4   
token   "共"
start_offset    4
end_offset  5
type    "<IDEOGRAPHIC>"
position    5
5   
token   "和"
start_offset    5
end_offset  6
type    "<IDEOGRAPHIC>"
position    6
6   
token   "國"
start_offset    6
end_offset  7
type    "<IDEOGRAPHIC>"
position    7


注意:2.0一下版本需要加index
    http://10.1.2.206:9200/your_index/_analyze?analyzer=standard&pretty=true&text=中華人民共和國

二、安裝

[root@bogon es]# git clone https://github.com/medcl/elasticsearch-analysis-ik
[root@bogon es]# cd elasticsearch-analysis-ik
[root@bogon es]# git tag --查看版本號
[root@bogon es]# git checkout tags/{version}
[root@bogon es]# mvn clean
[root@bogon es]# mvn compile
[root@bogon es]# mvn package
1.拷貝和解壓release下的文件: /elasticsearch-analysis-ik/target/releases/elasticsearch-analysis-ik-1.4.1-jar-with-dependencies.jar 到你的 elasticsearch 插件目錄, 如: plugins/ik 

2.拷貝config文件:/elasticsearch-analysis-ik/config/elasticsearch.yml中的內(nèi)容拷貝到es的config下elasticsearch.yml中(最下方)、其余的(ik文件夾和logging.yml)也拷貝到es的config下
圖片.png
圖片.png

三、測試

http://10.1.2.206:9200/beijing(索引名字)/_analyze?analyzer=ik&pretty=true&text=%E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91%E5%85%B1%E5%92%8C%E5%9B%BD

tokens  
0   
token   "中華人民共和國"
start_offset    0
end_offset  7
type    "CN_WORD"
position    1
1   
token   "中華人民"
start_offset    0
end_offset  4
type    "CN_WORD"
position    2
2   
token   "中華"
start_offset    0
end_offset  2
type    "CN_WORD"
position    3
3   
token   "華人"
start_offset    1
end_offset  3
type    "CN_WORD"
position    4
4   
token   "人民共和國"
start_offset    2
end_offset  7
type    "CN_WORD"
position    5
5   
token   "人民"
start_offset    2
end_offset  4
type    "CN_WORD"
position    6
6   
token   "共和國"
start_offset    4
end_offset  7
type    "CN_WORD"
position    7
7   
token   "共和"
start_offset    4
end_offset  6
type    "CN_WORD"
position    8
8   
token   "國"
start_offset    6
end_offset  7
type    "CN_CHAR"
position    9

圖片.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容