1.查询elasticsearch版本号(elasticsearch启动了)
访问es:http://192.168.111.131:9200/
页面展示:
{ "name" : "es-node1", "cluster_name" : "elasticsearch-cluster", "cluster_uuid" : "U4Em8zd3SDizdUzjwEKfAA", "version" : { "number" : "5.6.12", "build_hash" : "cfe3d9f", "build_date" : "2018-09-10T20:12:43.732Z", "build_snapshot" : false, "lucene_version" : "6.6.1" }, "tagline" : "You Know, for Search" }
"number" : "5.6.12"就是你的elasticsearch版本号
2.从github上获取相应版本的ikhttps://github.com/medcl/elasticsearch-analysis-ik
版本对照表
https://github.com/medcl/elasticsearch-analysis-ik/releases下载对应版本的压缩包,这里是5.6.12,下载elasticsearch-analysis-ik-5.6.12.zip
解压后从命名为ik
3.上传ik文件
在linux上将文件上传发到/usr/share/elasticsearch/plugins(此路径为docker启动es的文件挂载点)
4.重启es
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -p 5601:5601 -v /usr/local/es/config/es.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/es/plugins:/usr/share/elasticsearch/plugins -v /usr/local/es/data:/usr/share/elasticsearch/data --name ES elasticsearch
//此处有3个文件挂载,可以根据自己的文件所在路径修改挂载点
5.在postman中验证(ik_smart为ik分词器的分词模式,会做最粗粒度的拆分)
ik分词模式详解见链接https://blog.csdn.net/weixin_44062339/article/details/85006948
或者链接http://192.168.111.131:9200/_analyze?analyzer=ik_smart&text=华为
返回
{"tokens":[{"token":"华为","start_offset":0,"end_offset":2,"type":"CN_WORD","position":0}]}