提示1:必须保证之前的ES中不存在index, 否则ES集群无法启动, 会提示red!

提示2:下载的IK如果太新,会报错 TokenStream被重载Caused by: java.lang.VerifyError: class org.wltea.analyzer.lucene.IKAnalyzer overrides final method tokenStream.(Ljava/lang/String;Ljava/io/Reader;)Lorg/apache/lucene/analysis/TokenStream; 这个时候可以换一个旧的版本.

1.下载IK字典配置文件

http://download.csdn.net/detail/xxx0624/8464751

然后解压该文件(可以得到一个ik文件夹)并把它放到ES的config文件夹下.

2.下载 ik.jar

http://download.csdn.net/detail/xxx0624/8464743

下载后进入.plugins文件夹(若不存在 新建一个):

新建一个名字为analysis-ik的文件夹,再把下载的jar文件放入文件夹内

以上链接的jar包是最新的 可能不适用  你需要到github上下载旧版本的代码, 然后用mvn clean package来进行编译.

3.修改elasticsearch.yml(config文件夹中)

添加:

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

附上官方说明:

IK Analysis for ElasticSearch
================================== The IK Analysis plugin integrates Lucene IK analyzer into elasticsearch, support customized dictionary. Version
-------------
master | 0.90. -> master
1.1. | 0.90.
1.1. | 0.20.
1.1. | 0.19.x
1.0. | 0.16. -> 0.19. Install
-------------
you can download this plugin from RTF project(https://github.com/medcl/elasticsearch-rtf)
https://github.com/medcl/elasticsearch-rtf/tree/master/elasticsearch/plugins/analysis-ik
https://github.com/medcl/elasticsearch-rtf/tree/master/elasticsearch/config/ik <del>also remember to download the dict files,unzip these dict file into your elasticsearch's config folder,such as: your-es-root/config/ik</del> you need a service restart after that! Dict Configuration (es-root/config/ik/IKAnalyzer.cfg.xml)
------------- https://github.com/medcl/elasticsearch-analysis-ik/blob/master/config/ik/IKAnalyzer.cfg.xml <pre><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entry key="ext_dict">custom/mydict.dic;custom/sougou.dict</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords">custom/ext_stopword.dic</entry>
</properties> </pre> Analysis Configuration (elasticsearch.yml)
------------- <Pre>
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
</pre>
Or
<pre>
index.analysis.analyzer.ik.type : "ik"
</pre> you can set your prefer segment mode,default `use_smart` is false. Mapping Configuration
------------- Here is a quick example:
.create a index <pre> curl -XPUT http://localhost:9200/index </pre> .create a mapping <pre> curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'
{
"fulltext": {
"_all": {
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"term_vector": "no",
"store": "false"
},
"properties": {
"content": {
"type": "string",
"store": "no",
"term_vector": "with_positions_offsets",
"indexAnalyzer": "ik",
"searchAnalyzer": "ik",
"include_in_all": "true",
"boost":
}
}
}
}'
</pre> .index some docs <pre> curl -XPOST http://localhost:9200/index/fulltext/1 -d'
{content:"美国留给伊拉克的是个烂摊子吗"}
' curl -XPOST http://localhost:9200/index/fulltext/2 -d'
{content:"公安部:各地校车将享最高路权"}
' curl -XPOST http://localhost:9200/index/fulltext/3 -d'
{content:"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
' curl -XPOST http://localhost:9200/index/fulltext/4 -d'
{content:"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'
</pre> .query with highlighting <pre> curl -XPOST http://localhost:9200/index/fulltext/_search -d'
{
"query" : { "term" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}
'
</pre> here is the query result <pre> {
"took": ,
"timed_out": false,
"_shards": {
"total": ,
"successful": ,
"failed":
},
"hits": {
"total": ,
"max_score": ,
"hits": [
{
"_index": "index",
"_type": "fulltext",
"_id": "",
"_score": ,
"_source": {
"content": "中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"
},
"highlight": {
"content": [
"<tag1>中国</tag1>驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首 "
]
}
},
{
"_index": "index",
"_type": "fulltext",
"_id": "",
"_score": ,
"_source": {
"content": "中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"
},
"highlight": {
"content": [
"均每天扣1艘<tag1>中国</tag1>渔船 "
]
}
}
]
}
} </pre> have fun.

ElasticSearch使用IK中文分词---安装步骤记录的更多相关文章

  1. elasticsearch使用ik中文分词器

    elasticsearch使用ik中文分词器 一.背景 二.安装 ik 分词器 1.从 github 上找到和本次 es 版本匹配上的 分词器 2.使用 es 自带的插件管理 elasticsearc ...

  2. Elasticsearch:IK中文分词器

    Elasticsearch内置的分词器对中文不友好,只会一个字一个字的分,无法形成词语,比如: POST /_analyze { "text": "我爱北京天安门&quo ...

  3. elasticsearch ik中文分词器安装

    特殊说明:灰色文字用来辅助理解的. 安装IK中文分词器 我在百度上搜索了下,大多介绍的都是用maven打包下载下来的源码,这种方法也行,但是不够方便,为什么这么说? 首先需要安装maven吧?其次需要 ...

  4. 搜索引擎ElasticSearch系列(五): ElasticSearch2.4.4 IK中文分词器插件安装

    一:IK分词器简介  IK Analyzer是一个开源的,基于java语言开发的轻量级的中文分词工具包.从2006年12月推出1.0版开始, IKAnalyzer已经推出了4个大版本.最初,它是以开源 ...

  5. Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十九)ES6.2.2 安装Ik中文分词器

    注: elasticsearch 版本6.2.2 1)集群模式,则每个节点都需要安装ik分词,安装插件完毕后需要重启服务,创建mapping前如果有机器未安装分词,则可能该索引可能为RED,需要删除后 ...

  6. 30.IK中文分词器的安装和简单使用

    在之前我们学的都是英文,用的也是英文的standard分词器.从这一节开始,学习中文分词器.中国人基本上都是中文应用,很少是英文的,而standard分词器是没有办法对中文进行合理分词的,只是将每个中 ...

  7. Elasticsearch入门和查询语法分析(ik中文分词)

    全文搜索现在已经是很常见的功能了,当然你也可以用mysql加Sphinx实现.但开源的Elasticsearch(简称ES)目前是全文搜索引擎的首选.目前像GitHub.维基百科都使用的是ES,它可以 ...

  8. ElasticSearch速学 - IK中文分词器远程字典设置

    前面已经对”IK中文分词器“有了简单的了解:  但是可以发现不是对所有的词都能很好的区分,比如:  逼格这个词就没有分出来. 词库 实际上IK分词器也是根据一些词库来进行分词的,我们可以丰富这个词库. ...

  9. es5.0 安装ik中文分词器 mac

    es5.0集成ik中文分词器,网上资料很多,但是讲的有点乱,有的方法甚至不能正常运行此插件 特别注意的而是,es的版本一定要和ik插件的版本相对应: 1,下载ik 插件: https://github ...

随机推荐

  1. MySQL 设置允许远程登录

    1.修改数据表 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在 localhost 的那台电脑,登入MySQL后,更改 "MySQL" 数据库里的 &qu ...

  2. 安装MySQL的心得

    1.去官网上下载适合自己电脑的安装包,最好在网上查查教程起码知道自己应该怎么下载,下载哪一个. 2.我遇到的问题不多:<1>.没在bin目录下安装,启动数据库时出现错误2:<2> ...

  3. LoadRunner - 结果分析 / Result Analysis

    LoadRunner 最重要也是最难理解的地方--测试结果的分析.其余的录制和加压测试等设置对于我们来讲通过几次操作就可以轻松掌握了.针对 Results Analysis 我用图片加文字做了一个例子 ...

  4. 在51系列中data,idata,xdata,pdata的区别

    在51系列中data,idata,xdata,pdata的区别: data:固定指前面0x00-0x7f的128个RAM,可以用acc直接读写的,速度最快,生成的代码 也最小. idata:固定指前面 ...

  5. oracle增加表空间的四种方法,查询表空间使用情况

    增加表空间大小的四种方法Meathod1:给表空间增加数据文件ALTER TABLESPACE app_data ADD DATAFILE'D:\ORACLE\PRODUCT\10.2.0\ORADA ...

  6. windows+nginx+fcgi配置

    最近项目要求要学习一下nginx的知识,由于自己学疏才浅,搞了一天多终于基本搭建出来了,怕日后忘记,所以在此记录一下 nginx的历史,应用和种种就不记录了,自行百度.....Fcgi 相比cgi的好 ...

  7. Log4Net学习【三】

    Log4Net配置详解 配置方式一 在相应的应用程序的配置文件中配置,(WinForm对应的是*.exe.config,WebForm对应的是*.config),本实例是Web应用程序,以Web.co ...

  8. Hibernate使用原生sql语句

    异常类型1:could not extract resulted --->表名字和类名不一致 异常类型2:could not execute query---->可能是sql语句错: 异常 ...

  9. C#新语法特性前瞻

    今天逛微软的UserVoice site发现了几个有很有用,也很可能被添加到新版C#中的语法,当然也可能被推迟到下一版,拿出来给大家分享一下. 另外还没投票的可以去为自己最想要的新特性投票,有兴趣的可 ...

  10. 解决a different object with the same identifier value was already associated with the session错误

    [转]解决a different object with the same identifier value was already associated with the session错误 这个错 ...