一、安装ES
二、配置ik
1.下载ik
[https://github.com/medcl/elasticsearch-analysis-ik/releases]
(注意:版本最好与es对应)
2.打包(如果是下载zip,则跳过这一步)
使用maven对下载的es-ik源码(tar.gz)进行编译
3.解压
将压缩包复制到es安装目录下的/plugins/ik目录下面,然后使用unzip命令解压
三、测试
1.重启es
2.测试 ip/索引/_analyze
{
“analyzer”:“ik_max_word”, //ik_max_word:最细粒度划分;ik_smart:最少切分
“text”:“公安部:各地校车将享最高路权”
}
我是用的POSTMAN,在页面也可以直接操作
测试结果如下:
{
"tokens": [
{
"token": "公安部",
"start_offset": 0,
"end_offset": 3,
"type": "CN_WORD",
"position": 0
},
{
"token": "公安",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 1
},
{
"token": "部",
"start_offset": 2,
"end_offset": 3,
"type": "CN_CHAR",
"position": 2
},
{
"token": "各地",
"start_offset": 4,
"end_offset": 6,
"type": "CN_WORD",
"position": 3
},
{
"token": "校车",
"start_offset": 6,
"end_offset": 8,
"type": "CN_WORD",
"position": 4
},
{
"token": "将",
"start_offset": 8,
"end_offset": 9,
"type": "CN_CHAR",
"position": 5
},
{
"token": "享",
"start_offset": 9,
"end_offset": 10,
"type": "CN_CHAR",
"position": 6
},
{
"token": "最高",
"start_offset": 10,
"end_offset": 12,
"type": "CN_WORD",
"position": 7
},
{
"token": "路",
"start_offset": 12,
"end_offset": 13,
"type": "CN_CHAR",
"position": 8
},
{
"token": "权",
"start_offset": 13,
"end_offset": 14,
"type": "CN_CHAR",
"position": 9
}
]
}