首先确保机器应安装好elasticsearch服务,参考centos7安装运行Elasticsearch7.1。
插件版本和es版本要保持一致,直接运行以下命令完成安装,重启es即可。
[root@guangzhou elasticsearch]$ su elk && pwd /usr/local/elasticsearch [elk@guangzhou elasticsearch]$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip #安装成功查看下plugins目录,可见新增的文件analysis-ik [elk@guangzhou elasticsearch]$ ll plugins/ 总用量 4 drwxr-xr-x 2 elk elk 4096 2月 8 14:37 analysis-ik [elk@guangzhou elasticsearch]$ ll config/ 总用量 44 drwxr-x--- 2 elk elk 4096 2月 8 14:37 analysis-ik -rw-rw---- 1 elk elk 199 2月 7 16:08 elasticsearch.keystore -rw-rw---- 1 elk elk 2855 2月 8 16:16 elasticsearch.yml -rw-rw---- 1 elk elk 3544 2月 8 16:11 jvm.options -rw-rw---- 1 elk elk 17170 5月 23 2019 log4j2.properties -rw-rw---- 1 elk elk 473 5月 23 2019 role_mapping.yml -rw-rw---- 1 elk elk 197 5月 23 2019 roles.yml -rw-rw---- 1 elk elk 0 5月 23 2019 users -rw-rw---- 1 elk elk 0 5月 23 2019 users_roles #开两个窗口,一个启动elasticsearch,另一个输入以下命令,可以看到分词后的效果 [elk@guangzhou elasticsearch]$ curl -H 'Content-Type: application/json' -XGET 'localhost:9200/_analyze?pretty' -d '{"text":"热烈 庆祝沪昆高速开通"}' { "tokens" : [ { "token" : "热", "start_offset" : 0, "end_offset" : 1, "type" : "", "position" : 0 }, { "token" : "烈", "start_offset" : 1, "end_offset" : 2, "type" : " ", "position" : 1 }, { "token" : "庆", "start_offset" : 2, "end_offset" : 3, "type" : " ", "position" : 2 }, { "token" : "祝", "start_offset" : 3, "end_offset" : 4, "type" : " ", "position" : 3 }, { "token" : "沪", "start_offset" : 4, "end_offset" : 5, "type" : " ", "position" : 4 }, { "token" : "昆", "start_offset" : 5, "end_offset" : 6, "type" : " ", "position" : 5 }, { "token" : "高", "start_offset" : 6, "end_offset" : 7, "type" : " ", "position" : 6 }, { "token" : "速", "start_offset" : 7, "end_offset" : 8, "type" : " ", "position" : 7 }, { "token" : "开", "start_offset" : 8, "end_offset" : 9, "type" : " ", "position" : 8 }, { "token" : "通", "start_offset" : 9, "end_offset" : 10, "type" : " ", "position" : 9 } ] }