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 ...
随机推荐
- FileOutputStream字节输出流和FileInputStream输入流(切记:out是输出到本地中,in是输入到程序中)这里介绍大文件和小文件的读取方式
//FileOutputStream public class FileOutputStreamDemo { /**字节流:适用于任何文件,以字节为单位,进行读写操作 *字节流操作步骤: *1.创 ...
- 真与假与c#,java中的不同之处
/************真与假************/ /*C语言中:真(非0).假(0) * Java.C#中:真(true).假(false) * JavaScript中:真(非0.true. ...
- python+sublime text 2 中文乱码问题的解决方法[Decode error - output not utf-8]
打开sublime的preferences--browse packages找到python文件夹中的Python.sublime-build文件,把它拖到sublime里打开.在最后一行加入&quo ...
- 用C++进行简单的文件I/O操作-转自VC知识库
原文请见 http://www.vckbase.com/index.php/wv/1158 序论 我曾发表过文件输入输出的文章,现在觉得有必要再写一点.文件 I/O 在C++中比烤蛋糕简单多了. 在这 ...
- c#中queue的用法
Queue队列就是先进先出.它并没有实现 IList,ICollection.所以它不能按索引访问元素,不能使用Add和Remove.下面是 Queue的一些方法和属性 Enqueue():在队列的末 ...
- iOS基础 - Modal制作控制器
1.modal 1.modal推出控制器的代码 2.modal关闭当前控制器的代码 3.modal推出的动画效果 4.modal在ipad中应用 2.如何给控制器加上导航栏 3.modal和导航控制器 ...
- 用django搭建一个简易blog系统(翻译)(二)
03. Starting the blog app 在这部分,将要为你的project创建一个blog 应用,通过编辑setting.py文件,并把它添加到INSTALLED_APPS. 在你的命令行 ...
- 苹果icloud邮箱抓取
1 icloud登录,与其他网站登录区别 1.1 支持pop抓取的邮箱:pop提供统一接口,抓取简单: 1.2 没有前端js加密的邮箱(139,126,163):只要代码正确模拟登录流程,参数正确 ...
- SQL 语句中的union操作符
前端时间,用到了union操作符,周末有时间总结下,w3c手册内容如下: SQL UNION操作符 UNION操作符用于合并两个或多个select语句的结果集. 注意:UNION内部select语句必 ...
- 3分钟教你做一个iphone手机浏览器
3分钟教你做一个iphone手机浏览器 第一步:新建一个Single View工程: 第二步:新建好工程,关闭arc. 第三步:拖放一个Text Field 一个UIButton 和一个 UIWebV ...