/**

* 系统环境: vm12 下的centos 7.2

* 当前安装版本: elasticsearch-2.4.0.tar.gz

*/

ElasticSearch中内置了许多分词器, standard, english, chinese等, 中文分词效果不佳, 所以使用ik

安装ik分词器

下载链接: https://github.com/medcl/elasticsearch-analysis-ik/releases

版本对应关系: https://github.com/medcl/elasticsearch-analysis-ik

关闭elasticsearch.bat,将下载下来的压缩文件解压,在ES目录中的plugins文件夹里新建名为ik的文件夹,将解压得到的所有文件复制到ik中。

unzip elasticsearch-analysis-ik-1.10.0.zip

  确认 plugin-descriptor.properties 中的版本和安装的elasticsearch版本一直, 否则报异常

在elasticsearch.yml中增加ik设置

index.analysis.analyzer.ik.type : “ik”  

  或者添加:

index:
analysis:
analyzer:
ik:
alias: [ik_analyzer]
type: org.elasticsearch.index.analysis.IkAnalyzerProvider
ik_max_word:
type: ik
use_smart: false
ik_smart:
type: ik
use_smart: true

重新启动elasticsearch

注意: 不可将zip包放在在ik目录同级, 否则报错

Exception in thread "main" java.lang.IllegalStateException: Could not load plugin descriptor for existing plugin [elasticsearch-analysis-ik-1.10..zip]. Was the plugin built before 2.0?
Likely root cause: java.nio.file.FileSystemException: /usr/work/elasticsearch/elasticsearch-2.4./plugins/elasticsearch-analysis-ik-1.10..zip/plugin-descriptor.properties: 不是目录
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:)
at java.nio.file.Files.newByteChannel(Files.java:)
at java.nio.file.Files.newByteChannel(Files.java:)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:)
at java.nio.file.Files.newInputStream(Files.java:)
at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:)
at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:)
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:)
at org.elasticsearch.node.Node.<init>(Node.java:)
at org.elasticsearch.node.Node.<init>(Node.java:)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:)
Refer to the log for complete error details.

测试:

首先配置:

curl -XPUT localhost:/local -d '{
"settings" : {
"analysis" : {
"analyzer" : {
"ik" : {
"tokenizer" : "ik"
}
}
}
},
"mappings" : {
"article" : {
"dynamic" : true,
"properties" : {
"title" : {
"type" : "string",
"analyzer" : "ik"
}
}
}
}
}'

然后测试

curl 'http://localhost:9200/index/_analyze?analyzer=ik&pretty=true' -d'
{
"text":"中华人民共和国国歌"
}
'
{
"tokens" : [ {
"token" : "text",
"start_offset" : ,
"end_offset" : ,
"type" : "ENGLISH",
"position" :
}, {
"token" : "中华人民共和国",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}, {
"token" : "国歌",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
} ]
}

想要返回最细粒度的结果, 需要在elaticsearch.yml中配置

index:
analysis:
analyzer:
ik:
alias: [ik_analyzer]
type: org.elasticsearch.index.analysis.IkAnalyzerProvider
ik_smart:
type: ik
use_smart: true
ik_max_word:
type: ik
use_smart: false

elasticsearch插件安装之--中文分词器 ik 安装的更多相关文章

  1. ElasticSearch搜索引擎安装配置中文分词器IK插件

    近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...

  2. 如何给Elasticsearch安装中文分词器IK

    安装Elasticsearch安装中文分词器IK的步骤: 1. 停止elasticsearch 2.2的服务 2. 在以下地址下载对应的elasticsearch-analysis-ik插件安装包(版 ...

  3. ElasticSearch安装中文分词器IK

    1.安装IK分词器,下载对应版本的插件,elasticsearch-analysis-ik中文分词器的开发者一直进行维护的,对应着elasticsearch的版本,所以选择好自己的版本即可.IKAna ...

  4. 如何在Elasticsearch中安装中文分词器(IK)和拼音分词器?

    声明:我使用的Elasticsearch的版本是5.4.0,安装分词器前请先安装maven 一:安装maven https://github.com/apache/maven 说明: 安装maven需 ...

  5. 沉淀再出发:ElasticSearch的中文分词器ik

    沉淀再出发:ElasticSearch的中文分词器ik 一.前言   为什么要在elasticsearch中要使用ik这样的中文分词呢,那是因为es提供的分词是英文分词,对于中文的分词就做的非常不好了 ...

  6. 转:solr6.0配置中文分词器IK Analyzer

    solr6.0中进行中文分词器IK Analyzer的配置和solr低版本中最大不同点在于IK Analyzer中jar包的引用.一般的IK分词jar包都是不能用的,因为IK分词中传统的jar不支持s ...

  7. 我与solr(六)--solr6.0配置中文分词器IK Analyzer

    转自:http://blog.csdn.net/linzhiqiang0316/article/details/51554217,表示感谢. 由于前面没有设置分词器,以至于查询的结果出入比较大,并且无 ...

  8. 如何在Elasticsearch中安装中文分词器(IK+pinyin)

    如果直接使用Elasticsearch的朋友在处理中文内容的搜索时,肯定会遇到很尴尬的问题--中文词语被分成了一个一个的汉字,当用Kibana作图的时候,按照term来分组,结果一个汉字被分成了一组. ...

  9. docker 安装ElasticSearch的中文分词器IK

    首先确保ElasticSearch镜像已经启动 安装插件 方式一:在线安装 进入容器 docker exec -it elasticsearch /bin/bash 在线下载并安装 ./bin/ela ...

随机推荐

  1. cried me a river--kristinia debarge

    cried me a river--kristinia debarge I still remember the day that we metI hold on to every word you ...

  2. vc6.0 PK vs2010

    从VC++6.0不足看VisualC++2010新特性 说起VC,有人想到维生素C(维C),有人想到风险投资(venture capital), 程序员们尤其是做底层开发的程序员或老程序员们第一感觉肯 ...

  3. matlab的特殊字符(上下标和希腊字母等)

    'T=25\circC',(摄氏度) 下标用 _(下划线) 上标用^ (尖号) 希腊字母等特殊字符用 α \alpha β \beta γ \gamma θ \theta Θ \Theta Г \Ga ...

  4. Linux服务器目录空间不足解决措施

      一般情况下工作环境中我们的服务或数据库文件都会存储在一个单独挂载的分区中,一般占空间比较大的大多就是服务的运行日志以及数据库文件,当我们分区的可用空间不足时就需要我们对分区进行扩容,或者找其它方法 ...

  5. ActiveMQ5.0实战三:使用Spring发送,消费topic和queue消息

    实战一 , 实战二 介绍了ActiveMQ的基本概念和配置方式. 本篇将通过一个实例介绍使用spring发送,消费topic, queue类型消息的方法. 不懂topic和queue的google 之 ...

  6. python - http请求带Authorization

    # 背景 接入公司的一个数据统计平台,该平台的接口是带上了Authorization验证方式来保证验签计算安全 # 方法 其实很简单,就是在header中加入key=Authorization,val ...

  7. C# npoi 从excel导入datagridviews 批量联网核查

    DataSet ds = new DataSet(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Fil ...

  8. Android studio项目预览的时候提示错误ActionBarOverlayLayout

    android studio打开项目(别人的demo),提示页面没法预览.截图如下 根据查询,是主题没法正常显示,需要修改样式.样式文件的路径为res\values\styles.xml,截图如下. ...

  9. wpf 窗体翻页效果

    点击设置翻页,取消翻回来 1.xaml <Window x:Class="_3D翻页动画.MainWindow" xmlns="http://schemas.mic ...

  10. HI-LO计数法,赌桌,与机会

    HI-LO计数法,赌桌,与机会 “人只是在拼一种可能性”. 很多简单道理往往字面上理解容易,可实际运用难极. 一,那些人生中被扯的蛋 而关于人生的指导,好多耳熟能详的老话最终都被发现是蒙傻逼的.随便说 ...