ElasticSearch使用IK中文分词---安装步骤记录
提示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中文分词---安装步骤记录的更多相关文章
- elasticsearch使用ik中文分词器
elasticsearch使用ik中文分词器 一.背景 二.安装 ik 分词器 1.从 github 上找到和本次 es 版本匹配上的 分词器 2.使用 es 自带的插件管理 elasticsearc ...
- Elasticsearch:IK中文分词器
Elasticsearch内置的分词器对中文不友好,只会一个字一个字的分,无法形成词语,比如: POST /_analyze { "text": "我爱北京天安门&quo ...
- elasticsearch ik中文分词器安装
特殊说明:灰色文字用来辅助理解的. 安装IK中文分词器 我在百度上搜索了下,大多介绍的都是用maven打包下载下来的源码,这种方法也行,但是不够方便,为什么这么说? 首先需要安装maven吧?其次需要 ...
- 搜索引擎ElasticSearch系列(五): ElasticSearch2.4.4 IK中文分词器插件安装
一:IK分词器简介 IK Analyzer是一个开源的,基于java语言开发的轻量级的中文分词工具包.从2006年12月推出1.0版开始, IKAnalyzer已经推出了4个大版本.最初,它是以开源 ...
- Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十九)ES6.2.2 安装Ik中文分词器
注: elasticsearch 版本6.2.2 1)集群模式,则每个节点都需要安装ik分词,安装插件完毕后需要重启服务,创建mapping前如果有机器未安装分词,则可能该索引可能为RED,需要删除后 ...
- 30.IK中文分词器的安装和简单使用
在之前我们学的都是英文,用的也是英文的standard分词器.从这一节开始,学习中文分词器.中国人基本上都是中文应用,很少是英文的,而standard分词器是没有办法对中文进行合理分词的,只是将每个中 ...
- Elasticsearch入门和查询语法分析(ik中文分词)
全文搜索现在已经是很常见的功能了,当然你也可以用mysql加Sphinx实现.但开源的Elasticsearch(简称ES)目前是全文搜索引擎的首选.目前像GitHub.维基百科都使用的是ES,它可以 ...
- ElasticSearch速学 - IK中文分词器远程字典设置
前面已经对”IK中文分词器“有了简单的了解: 但是可以发现不是对所有的词都能很好的区分,比如: 逼格这个词就没有分出来. 词库 实际上IK分词器也是根据一些词库来进行分词的,我们可以丰富这个词库. ...
- es5.0 安装ik中文分词器 mac
es5.0集成ik中文分词器,网上资料很多,但是讲的有点乱,有的方法甚至不能正常运行此插件 特别注意的而是,es的版本一定要和ik插件的版本相对应: 1,下载ik 插件: https://github ...
随机推荐
- oracle 事务处理 注意事项(笔记)
事务:一个独立的逻辑工作单元.它有特定的一系列必须作为一个整体一起成功或者失败的SQL语句组成.是一个要么全有要么全无,很个性的一个东东. 事务的四大属性——ACID属性:原子性(atomicity) ...
- nginx 配置 ThinkPHP Rewrite
server { listen 80; server_name www.funsion.com; root /www/web/funsion; index index.php; location / ...
- poj 1383 Labyrinth
题目连接 http://poj.org/problem?id=1383 Labyrinth Description The northern part of the Pyramid contains ...
- 条款3:尽可能地使用const
如下为const修饰的几种类型: char name[] = "benxintuzi"; char* p1 = name; // non-const ...
- 自定义debug信息
#ifdef DEBUG #define debug(fmt,args...) printk(fmt ,##args) #define debugX(level,fmt,args...) if ...
- UIImageView swift
// // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fa ...
- Unity使用Kinect初级教程
准备 首先,你需要准备的东西 Windows 8以上系统的电脑,当然,配置不要太渣⊙︿⊙ Kinect for Windows开发套件 安装好Kinect for Windows SDK,这个应该属于 ...
- 校园导游之NABC个人分析
校园导游之NABC个人分析 Need: 为不熟悉校园环境的人们(如新生,来咱们学校参观滴)提供便利. Approach: 了解Andriod应用开发:导航功能之外还可以对学校进行宣传,比如拍一些学校的 ...
- 课题练习——找从1到N出现的1的个数
#include<iostream.h>#include<conio.h>int Sum1(int n){ int count = 0; //记录1的个数 int factor ...
- Jquery.ajax(……)
ajax 详细解释:http://www.cnblogs.com/mybest/archive/2011/12/13/2285730.html: 问题描述:页面发送ajax请求,服务器端返回代码总是进 ...