Elasticsearch5.4 安装中文插件的问题
来源:互联网 发布:淘宝专柜正品是真的吗 编辑:程序博客网 时间:2024/05/29 12:09
1:下载编译好的安装包:https://github.com/medcl/elasticsearch-analysis-ik/releases。注意下载版本要对应。2:下载好了之后解压,将解压后的文件夹放在elasticsearch目录下的plugins目录下,并重命名为analysis-ik3:将analysis-ik下config目录整个拷贝到elasticsearch目录下的config目录下,并重命名为ik4: 重启elasticsearch官网上的第一种方式总是报错 所以只能搞这种方式了二、分词器的使用1、ik带有两个分词器:
- ik_max_word :会将文本做最细粒度的拆分;尽可能多的拆分出词语
- ik_smart:会做最粗粒度的拆分;已被分出的词语将不会再次被其它词语占有看下边的例子就会明白他们的区别了:ik_smart: 在终端输入以下语句:
- curl -XGET 'http://127.0.0.1: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 } ]}
ik_max_word:
在终端输入以下内容:
curl -XGET 'http://127.0.0.1:9200/_analyze?pretty&analyzer=ik_max_word' -d '五星红旗迎风飘扬'
返回如下内容:
{ "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" : 0, "end_offset" : 1, "type" : "TYPE_CNUM", "position" : 2 }, { "token" : "星", "start_offset" : 1, "end_offset" : 2, "type" : "CN_CHAR", "position" : 3 }, { "token" : "红旗", "start_offset" : 2, "end_offset" : 4, "type" : "CN_WORD", "position" : 4 }, { "token" : "迎风", "start_offset" : 4, "end_offset" : 6, "type" : "CN_WORD", "position" : 5 }, { "token" : "飘扬", "start_offset" : 6, "end_offset" : 8, "type" : "CN_WORD", "position" : 6 }, { "token" : "飘", "start_offset" : 6, "end_offset" : 7, "type" : "CN_WORD", "position" : 7 }, { "token" : "扬", "start_offset" : 7, "end_offset" : 8, "type" : "CN_WORD", "position" : 8 } ]}
个人理解:ik_max_word相对来说 分词效果更细微了,所以效率就差了些
阅读全文