Elasticsearch 中文分词(elasticsearch-analysis-ik) 安装
由于elasticsearch基于lucene,所以天然地就多了许多lucene上的中文分词的支持,比如 IK, Paoding, MMSEG4J等lucene中文分词原理上都能在elasticsearch上使用。当然前提是有elasticsearch的插件。 至于插件怎么开发,这里有一片文章介绍:
http://log.medcl.net/item/2011/07/diving-into-elasticsearch-3-custom-analysis-plugin/
暂时还没时间看,留在以后仔细研究, 这里只记录本人使用medcl提供的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、因为是源代码,此处需要使用maven打包,进入解压文件夹中,执行命令:
4、将打包后,得到的目录文件target/releases下的elasticsearch-analysis-ik-1.9.4.zip复制到ES安装目录的plugins/analysis-ik目录下。

5、在plugins/analysis-ik目录下解压elasticsearch-analysis-ik-1.9.4.zip

6、在ES的配置文件elasticsearch.yml中增加ik的配置,在最后增加:
index.analysis.analyzer.ik.type: "ik"
7、重新启动elasticsearch服务,这样就完成配置了,收入命令:
curl -XPOST "http://localhost:9200/_analyze?analyzer=ik&pretty=true&text=helloworld,中华人民共和国"
测试结果如下:
{
"tokens" : [ {
"token" : "helloworld",
"start_offset" : 0,
"end_offset" : 10,
"type" : "ENGLISH",
"position" : 0
}, {
"token" : "中华人民共和国",
"start_offset" : 11,
"end_offset" : 18,
"type" : "CN_WORD",
"position" : 1
}, {
"token" : "中华人民",
"start_offset" : 11,
"end_offset" : 15,
"type" : "CN_WORD",
"position" : 2
}, {
"token" : "中华",
"start_offset" : 11,
"end_offset" : 13,
"type" : "CN_WORD",
"position" : 3
}, {
"token" : "华人",
"start_offset" : 12,
"end_offset" : 14,
"type" : "CN_WORD",
"position" : 4
}, {
"token" : "人民共和国",
"start_offset" : 13,
"end_offset" : 18,
"type" : "CN_WORD",
"position" : 5
}, {
"token" : "人民",
"start_offset" : 13,
"end_offset" : 15,
"type" : "CN_WORD",
"position" : 6
}, {
"token" : "共和国",
"start_offset" : 15,
"end_offset" : 18,
"type" : "CN_WORD",
"position" : 7
}, {
"token" : "共和",
"start_offset" : 15,
"end_offset" : 17,
"type" : "CN_WORD",
"position" : 8
}, {
"token" : "国",
"start_offset" : 17,
"end_offset" : 18,
"type" : "CN_CHAR",
"position" : 9
} ]
}
注意点:
本人绕了很多弯路,网上很多都不行,总结:
一、maven一定要编译,因为elasticsearch和ik各个版本不同,对应编译生成的文件就不同,所以想引用elasticsearch-rtm包的朋友,一定要注意区分。
二、我是通过rpm安装elasticsearch,事实证明字典config目录,可以在plugins目录下,和插件unzip放在一起
参考资料:
Elasticsearch初步使用(安装、Head配置、分词器配置)
Elasticsearch 中文分词(elasticsearch-analysis-ik) 安装的更多相关文章
- elasticsearch 中文分词(elasticsearch-analysis-ik)安装
elasticsearch 中文分词(elasticsearch-analysis-ik)安装 下载最新的发布版本 https://github.com/medcl/elasticsearch-ana ...
- elasticsearch 中文分词、插件的安装和使用(一)
1. 安装elasticsearch.kibana.x-pack #安装elasticsearch wget https://artifacts.elastic.co/downloads/elasti ...
- elasticsearch中文分词器(ik)配置
elasticsearch默认的分词:http://localhost:9200/userinfo/_analyze?analyzer=standard&pretty=true&tex ...
- Windows ElasticSearch中文分词配置
elasticsearch官方只提供smartcn这个中文分词插件,效果不是很好,好在国内有medcl大神(国内最早研究es的人之一)写的两个中文分词插件,一个是ik的,一个是mmseg的,下面分别介 ...
- ElasticSearch(三) ElasticSearch中文分词插件IK的安装
正因为Elasticsearch 内置的分词器对中文不友好,会把中文分成单个字来进行全文检索,所以我们需要借助中文分词插件来解决这个问题. 一.安装maven管理工具 Elasticsearch 要使 ...
- ElasticSearch中文分词(IK)
ElasticSearch常用的很受欢迎的是IK,这里稍微介绍下安装过程及测试过程. 1.ElasticSearch官方分词 自带的中文分词器很弱,可以体检下: [zsz@VS-zsz ~]$ c ...
- ElasticSearch 中文分词插件ik 的使用
下载 IK 的版本要与 Elasticsearch 的版本一致,因此下载 7.1.0 版本. 安装 1.中文分词插件下载地址:https://github.com/medcl/elasticsearc ...
- 实战ELK(8) 安装ElasticSearch中文分词器
安装 方法1 - download pre-build package from here: https://github.com/medcl/elasticsearch-analysis-ik/re ...
- elasticsearch中文分词器ik-analyzer安装
前面我们介绍了Centos安装elasticsearch 6.4.2 教程,elasticsearch内置的分词器对中文不友好,只会一个字一个字的分,无法形成词语,别急,已经有大拿把中文分词器做好了, ...
随机推荐
- zend server mac 下配置
Post Installation on Mac OS X If you intend to use PHP and other tools provided by Zend Server (pear ...
- FreeRTOS——任务调度—抢占式,时间片和合作式
以下转载自安富莱电子: http://forum.armfly.com/forum.php 本章教程为大家将介绍 FreeRTOS 操作系统支持的任务调度方式:抢占式,时间片和合作式,这部分算是 Fr ...
- ibatis中integer类型
假如java代码中设置的返回类型是integer类型,ibatis实际上返回的是BigDecimal,也就是说 ibatis转换成integer默认是bigdecimal类型的
- sqlmap中tamper脚本绕过waf
0x00 背景 sqlmap中的tamper脚本来对目标进行更高效的攻击. 由于乌云知识库少了sqlmap-tamper 收集一下,方便学习. 根据sqlmap中的tamper脚本可以学习过绕过一些技 ...
- RDD缓存学习
首先实现rdd缓存 准备了500M的数据 10份,每份 100万条,存在hdfs 中通过sc.textFile方法读取 val rdd1 = sc.textFile("hdfs://mini ...
- Flume Channel Selectors + kafka
http://flume.apache.org/FlumeUserGuide.html#custom-channel-selector 官方文档上channel selectors 有两种类型: Re ...
- am335x 打开内部 RTC
AM335X 打开内部 RTC 过程记录. kernel version: 3.2.0 先在 make menuconfig 里面打开内部RTC的配置: make menuconfig Device ...
- oozie调度中的重试和手工rerun一个workflow
在oozie中有Bundle.Coordinator和Workflow三种类型的job,他们之间可以有以下包含关系. Bundle > Coordinator > Workflow. 1. ...
- Entity Framework(七):Fluent API配置案例
一.配置主键 要显式将某个属性设置为主键,可使用 HasKey 方法.在以下示例中,使用了 HasKey 方法对 Product 类型配置 ProductId 主键. 1.新加Product类 usi ...
- Entity Framework(五):使用配置伙伴创建数据库
在上一篇文章中讲了如何使用fluent API来创建数据表,不知道你有没有注意到一个问题.上面的OnModelCreating方法中,我们只配置了一个类Product,也许代码不是很多,但也不算很少, ...