Elasticsearch安装中文分词插件ik

IK分词器 Elasticsearch插件地址:https://github.com/medcl/elasticsearch-analysis-ik
(注意下载对应的版本)

Versions
IK version ES version
master 7.x -> master
6.x 6.x
5.x 5.x
1.10.6 2.4.6
1.9.5 2.3.5
1.8.1 2.2.1
1.7.0 2.1.1
1.5.0 2.0.0
1.2.6 1.0.0
1.2.5 0.90.x
1.1.3 0.20.x
1.0.0 0.16.2 -> 0.19.0

#安装方法:将下载到的elasticsearch-analysis-ik-7.9.3.zip解压到/elasticsearch/plugins/ik
目录下即可。

#如果使用docker运行
docker cp /tmp/elasticsearch-analysis-ik-6.5.4.zip
elasticsearch:/usr/share/elasticsearch/plugins/
#进入容器
docker exec -it elasticsearch /bin/bash
mkdir /usr/share/elasticsearch/plugins/ik
cd /usr/share/elasticsearch/plugins/ik
unzip elasticsearch-analysis-ik-6.5.4.zip
#重启容器即可
docker restart elasticsearch

测试:
POST http://127.0.0.1:9200/itcast/_analyze
{
“analyzer”: “ik_max_word”,
“text”: “我是中国人”
}

结果:

{
tokens: [5]
0:  {
token: "我"
start_offset: 0
end_offset: 1
type: "CN_CHAR"
position: 0
}-
1:  {
token: "是"
start_offset: 1
end_offset: 2
type: "CN_CHAR"
position: 1
}-
2:  {
token: "中国人"
start_offset: 2
end_offset: 5
type: "CN_WORD"
position: 2
}-
3:  {
token: "中国"
start_offset: 2
end_offset: 4
type: "CN_WORD"
position: 3
}-
4:  {
token: "国人"
start_offset: 3
end_offset: 5
type: "CN_WORD"
position: 4
}-
-
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值