Elasticsearch安装中文分词插件ik
Elasticsearch默认提供的分词器,会把每一个汉字分开,而不是我们想要的依据关键词来分词。比如:
curl -XPOST "http://localhost:9200/userinfo/_analyze?analyzer=standard&pretty=true&text=我是中国人"
我们会得到这种结果:
{
tokens: [
{
token: text
start_offset: 2
end_offset: 6
type: <ALPHANUM>
position: 1
}
{
token: 我
start_offset: 9
end_offset: 10
type: <IDEOGRAPHIC>
position: 2
}
{
token: 是
start_offset: 10
end_offset: 11
type: <IDEOGRAPHIC>
position: 3
}
{
token: 中
start_offset: 11
end_offset: 12
type: <IDEOGRAPHIC>
position: 4
}
{
token: 国
start_offset: 12
end_offset: 13
type: <IDEOGRAPHIC>
position: 5
}
{
token: 人
start_offset: 13
end_offset: 14
type: <IDEOGRAPHIC>
position: 6
}
]
}
正常情况下。这不是我们想要的结果,比方我们更希望 “中国人”,“中国”,“我”这种分词。这样我们就须要安装中文分词插件,ik就是实现这个功能的。
elasticsearch-analysis-ik
是一款中文的分词插件,支持自己定义词库。
安装步骤:
1、到github站点下载源码。站点地址为:https://github.com/medcl/elasticsearch-analysis-ik
右側下方有一个button“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 package
5、将打包得到的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: text
start_offset: 2
end_offset: 6
type: ENGLISH
position: 1
}
{
token: 我
start_offset: 9
end_offset: 10
type: CN_CHAR
position: 2
}
{
token: 中国人
start_offset: 11
end_offset: 14
type: CN_WORD
position: 3
}
{
token: 中国
start_offset: 11
end_offset: 13
type: CN_WORD
position: 4
}
{
token: 国人
start_offset: 12
end_offset: 14
type: CN_WORD
position: 5
}
]
}
说明:
1、ES安装插件本来使用使用命令plugin来完毕。可是我本机安装ik时一直不成功,所以就使用源码打包安装了。
2、自己定义词库的方式,请參考 https://github.com/medcl/elasticsearch-analysis-ik
Elasticsearch安装中文分词插件ik的更多相关文章
- 如何给Elasticsearch安装中文分词器IK
安装Elasticsearch安装中文分词器IK的步骤: 1. 停止elasticsearch 2.2的服务 2. 在以下地址下载对应的elasticsearch-analysis-ik插件安装包(版 ...
- ElasticSearch安装中文分词器IK
1.安装IK分词器,下载对应版本的插件,elasticsearch-analysis-ik中文分词器的开发者一直进行维护的,对应着elasticsearch的版本,所以选择好自己的版本即可.IKAna ...
- Elasticsearch如何安装中文分词插件ik
elasticsearch-analysis-ik 是一款中文的分词插件,支持自定义词库. 安装步骤: 1.到github网站下载源代码,网站地址为:https://github.com/medcl/ ...
- ElasticSearch-5.0.0安装中文分词插件IK
Install IK 源码地址:https://github.com/medcl/elasticsearch-analysis-ik,git clone下来. 1.compile mvn packag ...
- elasticsearch安装中文分词器插件smartcn
原文:http://blog.java1234.com/blog/articles/373.html elasticsearch安装中文分词器插件smartcn elasticsearch默认分词器比 ...
- 如何在Elasticsearch中安装中文分词器(IK)和拼音分词器?
声明:我使用的Elasticsearch的版本是5.4.0,安装分词器前请先安装maven 一:安装maven https://github.com/apache/maven 说明: 安装maven需 ...
- 沉淀再出发:ElasticSearch的中文分词器ik
沉淀再出发:ElasticSearch的中文分词器ik 一.前言 为什么要在elasticsearch中要使用ik这样的中文分词呢,那是因为es提供的分词是英文分词,对于中文的分词就做的非常不好了 ...
- ElasticSearch 安装中文分词器
1.安装中文分词器IK 下载地址:https://github.com/medcl/elasticsearch-analysis-ik 在线下载安装: elasticsearch-plugin.bat ...
- ElasticSearch安装中文分词器IKAnalyzer
# ElasticSearch安装中文分词器IKAnalyzer 本篇主要讲解如何在ElasticSearch中安装中文分词器IKAnalyzer,拆分的每个词都是我们熟知的词语,从而建立词汇与文档 ...
随机推荐
- Shell基础笔记一
由于工作需要,开始学习Shell编程,都是一些简单的基础知识,现整理收集分享出来,希望对大家有帮助 -------------------------------------------------- ...
- HDU_1520_Anniversary party_树型dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 Anniversary party Time Limit: 2000/1000 MS (Java ...
- Jmeter在Windows上分布式压测遇到的坑
1.五星坑:远程启动测试,响应数据为空. controller运行jmeter脚本后,GUI无性能数据返回. agent的jmeter server显示连接后立即结束.看似执行实则响应数据为空. 出现 ...
- vue项目 build之后发布到服务器index.html页面空白解决方法
第一部分 之前一直不太理解为什么要使用vue+webapck,还有在使用了vue-cli之后会用到后台,即vue-cli自动帮我们安装了express服务器,在本地服务器上运行,因为我们希望可以模拟在 ...
- oracle数据库子查询的结果需要使用多次解决办法
with c as (select a.trandt,sum(a.tranam) tranam from tran a group by a.trandt )--将子查询抽取出来,以后可以直接用.该方 ...
- PMP 学习心得
前两天刚考完 PMP,松了一口气,终于考完了,虽然心里有点慌,不知道自己会不会过.学习 PMP 这三个月还是很充实的.不断的看视频,做题目,功夫不负有心人,也算是学到了一些东西.至少知道了一个项目的启 ...
- day02 Python完结
一. 常用数据类型及内置法 1 列表 定义: 列表是Python中内置有序.可变序列,列表的所有元素放在一对中括号“[]”中,并使用逗号分隔开: 当列表元素增加或删除时,列表对象自动进行扩展或收缩内存 ...
- UVA - 514 Rails(栈模拟)
题目: 给出一个序列,问将1,2,3,4……按从小到大的顺序入栈,能否得到给出的序列. 思路: 用stack模拟就可以了. 当前的cnt如果小于a[i],就将cnt入栈,否则就判断栈顶是不是和a[i] ...
- centos下kong源码安装
参考资料: https://docs.konghq.com/install/source/ 环境准备:操作系统 centeros7.3 1 :openssl和pcre一般系统自带,如果没有可自己安装 ...
- idea 背景颜色设置
1. 设置当前鼠标所在行颜色 2. 设置编辑区颜色