Elasticsearch安装ik中文分词插件(四)
一、IK简介
IK Analyzer是一个开源的,基于java语言开发的轻量级的中文分词工具包。从2006年12月推出1.0版开始, IKAnalyzer已经推出了4个大版本。最初,它是以开源项目Luence为应用主体的,结合词典分词和文法分析算法的中文分词组件。从3.0版本开 始,IK发展为面向Java的公用分词组件,独立于Lucene项目,同时提供了对Lucene的默认优化实现。在2012版本中,IK实现了简单的分词 歧义排除算法,标志着IK分词器从单纯的词典分词向模拟语义分词衍化。
IK Analyzer 2012特性:
- 采用了特有的“正向迭代最细粒度切分算法“,支持细粒度和智能分词两种切分模式。
- 在系统环境:Core2 i7 3.4G双核,4G内存,window 7 64位, Sun JDK 1.6_29 64位 普通pc环境测试,IK2012具有160万字/秒(3000KB/S)的高速处理能力。
- 2012版本的智能分词模式支持简单的分词排歧义处理和数量词合并输出。
- 采用了多子处理器分析模式,支持:英文字母、数字、中文词汇等分词处理,兼容韩文、日文字符。
- 优化的词典存储,更小的内存占用。支持用户词典扩展定义。特别的,在2012版本,词典支持中文,英文,数字混合词语。
二、配置编译环境
从Github下载的IK分词是源码包,需要maven环境编译
1、下载maven
# wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
2、解压
# tar zxf apache-maven-3.3.-bin.tar.gz -C /usr/src/
3、配置环境变量
# vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.3.
export PATH=$PATH:$MAVEN_HOME/bin
# source /etc/profile
三、安装IK分词插件
1、下载
到GitHub上下载适合ElasticSearch版本的IK,地址:https://github.com/medcl/elasticsearch-analysis-ik;也可以通过git clone https://github.com/medcl/elasticsearch-analysis-ik,下载分词器源码。
2、解压编译
# unzip elasticsearch-analysis-ik-master.zip
# cd elasticsearch-analysis-ik-master/
# mvn clean package
3、复制编译完成的IK分词到elasticsearch的插件路径
# mkdir $elasticsearch/plugins/ik
# cp target/releases/elasticsearch-analysis-ik-1.9..zip $elasticsearch/plugins/ik/
# cd $elasticsearch/plugins/ik/
# unzip elasticsearch-analysis-ik-1.9..zip
4、重启elasticsearch,使ik插件生效
# /etc/init.d/elasticsearch restart
四、ik分词测试
1、创建一个索引,名为“index”
# curl -XPUT http://localhost:9200/index
2、为“index”创建mapping
# curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'
{
"fulltext": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"content": {
"type": "string",
"store": "no",
"term_vector": "with_positions_offsets",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"include_in_all": "true",
"boost":
}
}
}
}'
3、测试
# curl 'http://10.10.10.26:9200/index/_analyze?analyzer=ik&pretty=true' -d '{"text":"中华人民共和国国歌"}'
显示如下:
{
"tokens" : [ {
"token" : "中华人民共和国",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "中华人民",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "中华",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "华人",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "人民共和国",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "人民",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "共和国",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "共和",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "国",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_CHAR",
"position" :
}, {
"token" : "国歌",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
} ]
}
elasticsearch-analysis-ik的Github地址:https://github.com/medcl/elasticsearch-analysis-ik
Elasticsearch安装ik中文分词插件(四)的更多相关文章
- elasticsearch 安装ik中文分词
https://blog.csdn.net/c5113620/article/details/79339541
- elasticsearch使用ik中文分词器
elasticsearch使用ik中文分词器 一.背景 二.安装 ik 分词器 1.从 github 上找到和本次 es 版本匹配上的 分词器 2.使用 es 自带的插件管理 elasticsearc ...
- Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十九)ES6.2.2 安装Ik中文分词器
注: elasticsearch 版本6.2.2 1)集群模式,则每个节点都需要安装ik分词,安装插件完毕后需要重启服务,创建mapping前如果有机器未安装分词,则可能该索引可能为RED,需要删除后 ...
- Elasticsearch:IK中文分词器
Elasticsearch内置的分词器对中文不友好,只会一个字一个字的分,无法形成词语,比如: POST /_analyze { "text": "我爱北京天安门&quo ...
- es5.0 安装ik中文分词器 mac
es5.0集成ik中文分词器,网上资料很多,但是讲的有点乱,有的方法甚至不能正常运行此插件 特别注意的而是,es的版本一定要和ik插件的版本相对应: 1,下载ik 插件: https://github ...
- 在ElasticSearch中使用 IK 中文分词插件
我这里集成好了一个自带IK的版本,下载即用, https://github.com/xlb378917466/elasticsearch5.2.include_IK 添加了IK插件意味着你可以使用ik ...
- ElasticSearch使用IK中文分词---安装步骤记录
提示1:必须保证之前的ES中不存在index, 否则ES集群无法启动, 会提示red! 提示2:下载的IK如果太新,会报错 TokenStream被重载Caused by: java.lang.Ver ...
- es(elasticsearch)安装IK中文分词器
IK压缩包下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v6.7.0,需要下载对应的版本 我也上传了 h ...
- solr - 安装ik中文分词 和初始化富文本检索
1.下载安装包 https://repo1.maven.org/maven2/org/apache/solr/solr-dataimporthandler/7.4.0/solr-dataimporth ...
随机推荐
- visual studio code, asp.net5, mvc6资料汇总
最近在试探性地跟随微软最新发布的一些产品,现列下某些挺好的文章和链接 code.visualstudio.com http://blogs.msdn.com/b/cesardelatorre/arch ...
- ExpandoObject,DynamicObject,DynamicMetaObject
ExpandoObject,DynamicObject,DynamicMetaObject 接上文:浅谈Dynamic关键字系列之三(上) 为什么TryXXX方法没有被调用?? 将DynamicPro ...
- hdu 1239 Calling Extraterrestrial Intelligence Again (暴力枚举)
Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- JSP技术模型(五)JSP隐含变量
在JSP页面的转换阶段,容器在_jspService()方法中申明并初始化一些变量,可以在JSP页面小脚本中或表达式中直接使用这些变量. 一.JSP页面中可使用的隐含变量 1.applicationj ...
- C#外挂QQ
C#外挂QQ找茬辅助源码,早期开发 这是一款几年前开发的工具,当年作为一民IT纯屌,为了当年自己心目中的一位女神熬夜开发完成.女神使用后找茬等级瞬间从眼明手快升级为三只眼...每次看到这个就会想起 ...
- SZU:L89 Frog Encoding
Judge Info Memory Limit: 65536KB Case Time Limit: 3000MS Time Limit: 3000MS Judger: Normal Descripti ...
- [转]OpenSolaris 2009.06, dev setup
Source:http://seriouswebapps.com/opensolaris-200906-dev-setup 1. Snapshot the root zfs pool This all ...
- [转]ARM Pipeline
Add r0, PC, # g_oalAddressTable - (+ 8) instruction, a lot of people had cprogramdev.com Forum asked ...
- UI基础UIWindow、UIView
UI基础UIWindow.UIView 在PC中,应用程序多是使用视窗的形式显示内容,手机应用也不例外,手机应用中要在屏幕上显示内容首先要创建一个窗口承载内容,iOS应用中使用UIWindow.UIV ...
- QQ空间如何显示相片
QQ空间如何显示相片 前言 此篇文章估计不会太长,有移除首页的风险,但是老夫(称老夫是因为我们真正的叶小钗其实都100多岁啦)是不会怕滴.所以,我来了哟! 题外话:今天我们一起还看了一道前端的面试题, ...