下载ik分词器
地址:下载es向匹配的版本
安装
上传到指定目录:/opt/es
将插件解压至一下目录:
unzip -d data1/plugin/ik/ elasticsearch-analysis-ik-7.4.0.zip
unzip -d data2/plugin/ik/ elasticsearch-analysis-ik-7.4.0.zip
unzip -d data3/plugin/ik/ elasticsearch-analysis-ik-7.4.0.zip
直接启动即可,data1/plugin
会挂载到容器的/usr/share/elasticsearch/plugins
验证
请求:
POST 192.168.101.6:9200/_analyze
Content-Type:application/json; charset=UTF-8
{
"analyzer":"ik_max_word",
"text":"农业银行"
}
结果:
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
{
"tokens": [
{
"token": "农业银行",
"start_offset": 0,
"end_offset": 4,
"type": "CN_WORD",
"position": 0
},
{
"token": "农业",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 1
},
{
"token": "银行",
"start_offset": 2,
"end_offset": 4,
"type": "CN_WORD",
"position": 2
}
]
}