由于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. IOS7 隐藏状态栏 (电池栏)

    电池状态栏. //方法一(代码设置): 现在ios7已经更改为透明,并且不占用屏幕高度.其中隐藏及显示的方法如下: 在uiviewcontroller的子类下,调用:     if ([self re ...

  2. Oracle 11g安装图文攻略

    一.Oracle 下载 注意Oracle分成两个文件,下载完后,将两个文件解压到同一目录下即可. 路径名称中,最好不要出现中文,也不要出现空格等不规则字符. 官方下地址: http://www.ora ...

  3. js prototype 理解

    简单理解:prototype对象是实现面向对象的一个重要机制.每个函数也是一个对象,它们对应的类就是 function,每个函数对象都具有一个子对象prototype.Prototype 表示了该函数 ...

  4. hadoop三大组件的简单图解

    如有不对,欢迎大家指正

  5. https 单向双向认证说明_数字证书, 数字签名, SSL(TLS) , SASL_转

    转自:https 单向双向认证说明_数字证书, 数字签名, SSL(TLS) , SASL 因为项目中要用到TLS + SASL 来做安全认证层. 所以看了一些网上的资料, 这里做一个总结. 1. 首 ...

  6. Bus error (core dumped) 我重启了下superviser 资源cpu占用高

    python policy.py Bus error (core dumped) 我重启了下superviser

  7. thinkphp 如何调用百度echarts 数据报表插件

    echarts官网网址:http://echarts.baidu.com/ echarts源码地址:http://echarts.baidu.com/build/echarts-2.2.7.zip   ...

  8. 点击edittext并显示其内容

    package com.example.sum;//sum import com.example.sum.R;//sum import android.app.Activity; import and ...

  9. [转]Shell脚本中获取SELECT结果值的方法

    http://blog.itpub.net/13885898/viewspace-1670297/ 有时候我们可能会需要在Shell脚本中执行SELECT语句,并将结果赋值给一个变量,对于这样的情形, ...

  10. python入门(七):CGI编程

    CGI CGI(Common Gateway Interface),通用网关接口,HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序须运行在网络服务器上. CGI在其中扮演的是在we ...