Elasticsearch安装中文分词插件ik
来源:互联网 发布:少年包青天1 知乎 编辑:程序博客网 时间:2024/04/28 00:34
Elasticsearch默认提供的分词器,会把每个汉字分开,而不是我们想要的根据关键词来分词。例如:
curl -XPOST "http://localhost:9200/userinfo/_analyze?analyzer=standard&pretty=true&text=我是中国人"我们会得到这样的结果:
{tokens: [{token: textstart_offset: 2end_offset: 6type: <ALPHANUM>position: 1}{token: 我start_offset: 9end_offset: 10type: <IDEOGRAPHIC>position: 2}{token: 是start_offset: 10end_offset: 11type: <IDEOGRAPHIC>position: 3}{token: 中start_offset: 11end_offset: 12type: <IDEOGRAPHIC>position: 4}{token: 国start_offset: 12end_offset: 13type: <IDEOGRAPHIC>position: 5}{token: 人start_offset: 13end_offset: 14type: <IDEOGRAPHIC>position: 6}]}正常情况下,这不是我们想要的结果,比如我们更希望 “中国人”,“中国”,“我”这样的分词,这样我们就需要安装中文分词插件,ik就是实现这个功能的。
elasticsearch-analysis-ik 是一款中文的分词插件,支持自定义词库。
安装步骤:
1、到github网站下载源代码,网站地址为:https://github.com/medcl/elasticsearch-analysis-ik
右侧下方有一个按钮“Download ZIP",点击下载源代码elasticsearch-analysis-ik-master.zip。
2、解压文件elasticsearch-analysis-ik-master.zip,进入下载目录,执行命令:
unzip elasticsearch-analysis-ik-master.zip
3、将解压目录文件中config/ik文件夹复制到ES安装目录config文件夹下。
4、因为是源代码,此处需要使用maven打包,进入解压文件夹中,执行命令:mvn clean package5、将打包得到的jar文件elasticsearch-analysis-ik-1.2.8-sources.jar复制到ES安装目录的lib目录下。
6、在ES的配置文件config/elasticsearch.yml中增加ik的配置,在最后增加:
index: analysis: analyzer: ik: alias: [ik_analyzer] type: org.elasticsearch.index.analysis.IkAnalyzerProvider ik_max_word: type: ik use_smart: false ik_smart: type: ik use_smart: true或
index.analysis.analyzer.ik.type : “ik”7、重新启动elasticsearch服务,这样就完成配置了,收入命令:
curl -XPOST "http://localhost:9200/userinfo/_analyze?analyzer=ik&pretty=true&text=我是中国人"测试结果如下:
{tokens: [{token: textstart_offset: 2end_offset: 6type: ENGLISHposition: 1}{token: 我start_offset: 9end_offset: 10type: CN_CHARposition: 2}{token: 中国人start_offset: 11end_offset: 14type: CN_WORDposition: 3}{token: 中国start_offset: 11end_offset: 13type: CN_WORDposition: 4}{token: 国人start_offset: 12end_offset: 14type: CN_WORDposition: 5}]}说明:
1、ES安装插件本来使用使用命令plugin来完成,但是我本机安装ik时一直不成功,所以就使用源代码打包安装了。
2、自定义词库的方式,请参考 https://github.com/medcl/elasticsearch-analysis-ik
2 0
- Elasticsearch安装中文分词插件ik
- Elasticsearch安装中文分词插件ik
- Elasticsearch安装中文分词插件ik
- Elasticsearch中文分词插件ik的安装
- Elasticsearch如何安装中文分词插件ik
- Elasticsearch如何安装中文分词插件ik
- Elasticsearch中文分词ik插件安装
- 安装Elasticsearch analysis ik中文分词插件
- Elasticsearch安装中文分词插件ik
- ElasticSearch安装ik分词插件
- ElasticSearch安装ik分词插件
- ElasticSearch 安装 ik 分词插件
- ElasticSearch安装ik分词插件
- ElasticSearch安装ik分词插件
- ElasticSearch中文分词ik安装
- ElasticSearch中文分词IK安装
- elasticsearch 2.3.4中文分词插件ik 1.9.4安装
- Elasticsearch中文分词插件IK Analyer安装操作指导
- 在android中画圆形图片的几种办法
- 系统调用跟我学(4)
- dwr异常处理
- Aizu 2304 Reverse Roads 网络流
- win8.1和ubuntu14.04双系统安装
- Elasticsearch安装中文分词插件ik
- grub2学习和Boot-Repair
- 字符串
- Linux下配置Oracle监听器
- sftp常用命令介绍
- objective c 中的Blocks语法
- HDU-#5019 Revenge of GCD(枚举)
- 腾讯2015校园招聘技术类研发笔试题
- MyEclipse出现Unrecognized Windows Sockets error: 0: JVM_Bind