由于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中文分词

elasticsearch安装plugin----ik

ElasticSearch中文分词ik安装

Elasticsearch初步使用(安装、Head配置、分词器配置)

Elasticsearch 中文分词(elasticsearch-analysis-ik) 安装的更多相关文章

  1. elasticsearch 中文分词(elasticsearch-analysis-ik)安装

    elasticsearch 中文分词(elasticsearch-analysis-ik)安装 下载最新的发布版本 https://github.com/medcl/elasticsearch-ana ...

  2. elasticsearch 中文分词、插件的安装和使用(一)

    1. 安装elasticsearch.kibana.x-pack #安装elasticsearch wget https://artifacts.elastic.co/downloads/elasti ...

  3. elasticsearch中文分词器(ik)配置

    elasticsearch默认的分词:http://localhost:9200/userinfo/_analyze?analyzer=standard&pretty=true&tex ...

  4. Windows ElasticSearch中文分词配置

    elasticsearch官方只提供smartcn这个中文分词插件,效果不是很好,好在国内有medcl大神(国内最早研究es的人之一)写的两个中文分词插件,一个是ik的,一个是mmseg的,下面分别介 ...

  5. ElasticSearch(三) ElasticSearch中文分词插件IK的安装

    正因为Elasticsearch 内置的分词器对中文不友好,会把中文分成单个字来进行全文检索,所以我们需要借助中文分词插件来解决这个问题. 一.安装maven管理工具 Elasticsearch 要使 ...

  6. ElasticSearch中文分词(IK)

    ElasticSearch常用的很受欢迎的是IK,这里稍微介绍下安装过程及测试过程.   1.ElasticSearch官方分词 自带的中文分词器很弱,可以体检下: [zsz@VS-zsz ~]$ c ...

  7. ElasticSearch 中文分词插件ik 的使用

    下载 IK 的版本要与 Elasticsearch 的版本一致,因此下载 7.1.0 版本. 安装 1.中文分词插件下载地址:https://github.com/medcl/elasticsearc ...

  8. 实战ELK(8) 安装ElasticSearch中文分词器

    安装 方法1 - download pre-build package from here: https://github.com/medcl/elasticsearch-analysis-ik/re ...

  9. elasticsearch中文分词器ik-analyzer安装

    前面我们介绍了Centos安装elasticsearch 6.4.2 教程,elasticsearch内置的分词器对中文不友好,只会一个字一个字的分,无法形成词语,别急,已经有大拿把中文分词器做好了, ...

随机推荐

  1. 《Kubernetes与云原生应用》系列之容器设计模式

    http://www.infoq.com/cn/articles/kubernetes-and-cloud-native-app-container-design-pattern <Kubern ...

  2. 0068 Git入门的第一节课

    这是 猴子都懂的Git入门 的学习笔记 Git安装与配置 下载安装Git:http://git-scm.com/ 从开始菜单启动Git Bash $ git --version git version ...

  3. oracle spfile pfile

    1.如果不指定的話 先后順序: spfileSID.ora spfile.ora initSID.ora init.ora. 2.这样startup spfile='*.oar',不允许的. 3.不过 ...

  4. org.apache.hadoop.hbase.DoNotRetryIOException: Class org.apache.phoenix.coprocessor.MetaDataEndpointImpl cannot be loaded Set hbase.table.sanity.checks to false at conf or table descriptor if you want

    https://stackoverflow.com/questions/38495331/apache-phoenix-unable-to-connect-to-hbase 这个坑不该啊 首选配置hb ...

  5. UCOS2_STM32移植详细过程(汇总)

    Ⅰ.概述 笔者发现一个问题,很多初学者,甚至很多工作一两年的人,他们有一种依赖的思想,就是希望从别处获取的软件代码不做任何修改,直接可以运行或者使用.笔者想说,实践才是检验真理的关键,实践才是掌握知识 ...

  6. Python高级编程之生成器(Generator)与coroutine(一):Generator

    转载请注明出处:点我 这是一系列的文章,会从基础开始一步步的介绍Python中的Generator以及coroutine(协程)(主要是介绍coroutine),并且详细的讲述了Python中coro ...

  7. Toad 补充与培训 & 常用菜单

    Toad 常用菜单 新版本 toad 软件中, 比较有用的菜单 (toad10.6 版本) 下边菜单, 在日常工作中出现过的, 显示为 粉色 , 蓝色 表示次一级的重要 session 菜单 new ...

  8. Spring Cloud都做了哪些事

    Spring Cloud是一系列框架的有序集合.它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册.配置中心.消息总线.负载均衡.断路器.数据监控等,都可以用 ...

  9. 如果没有指定Cookie的时效,那么默认的时效是。(选择1项)

    如果没有指定Cookie的时效,那么默认的时效是.(选择1项) A.一天 B. 永不过期 C.会话级别 D.一分钟 解答:C 这是API的原文:By default, -1 indicating th ...

  10. backbone.js初探(转)

    BackBone是JavaScript frameworks for creating MVC-like web applications,最近流行的用来建立单页面web application的工具 ...