官方文档:
|
1
|
https://github.com/medcl/elasticsearch-analysis-ik |
创建目录:
|
1
2
|
cd xxx/plugins/mkdir ik |
查看版本:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# curl -XGET localhost:9200{ "name" : "es1", "cluster_name" : "vphotoses", "cluster_uuid" : "1q0u6R63QXGGgcfVegPqQg", "version" : { "number" : "5.3.0", "build_hash" : "3adb13b", "build_date" : "2017-03-23T03:31:50.652Z", "build_snapshot" : false, "lucene_version" : "6.4.1" }, "tagline" : "You Know, for Search"} |
下载插件:版本号要和elasticsearch完全一致,否者安装失败es重启不了。
|
1
|
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.3.0/elasticsearch-analysis-ik-5.3.0.zip |
解压到ik目录即可:
|
1
|
unzip elasticsearch-analysis-ik-5.3.0.zip |
重启elasticsearch即可。
查看已经安装的插件:
|
1
2
3
|
# curl -XGET localhost:9200/_cat/pluginses1 analysis-ik 5.3.0es2 analysis-ik 5.3.0 |
使用分词:
在命令行中:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# curl -XGET 'http://localhost:9200/_analyze?pretty&analyzer=ik_smart' -d '五星红旗迎风飘扬'{ "tokens" : [ { "token" : "五星红旗", "start_offset" : 0, "end_offset" : 4, "type" : "CN_WORD", "position" : 0 }, { "token" : "迎风", "start_offset" : 4, "end_offset" : 6, "type" : "CN_WORD", "position" : 1 }, { "token" : "飘扬", "start_offset" : 6, "end_offset" : 8, "type" : "CN_WORD", "position" : 2 } ]} |
或打开如下web页面
|
1
|
http://10.64.104.43:5601/app/kibana#/dev_tools/console?_g=() |
在console输入框中输入如下内容再点击发送按钮:
|
1
2
3
4
5
|
post _analyze{ "text":"五星红旗迎风飘扬" ,"analyzer":"ik_max_word"} |

本文来自博客园,作者:大码王,转载请注明原文链接:https://www.cnblogs.com/huanghanyu/
posted on
浙公网安备 33010602011771号