为Elasticsearch安装中文分词IK
来源:互联网 发布:手机拍照后期制作软件 编辑:程序博客网 时间:2024/03/28 21:47
原文地址: http://www.mamicode.com/info-detail-439214.html
注:Elasticsearch版本:1.4.4
一、安装与配置
1.从https://github.com/medcl/elasticsearch-analysis-ik下载elasticsearch-analysis-ik-master.zip
注意,下载时, 版本号要匹配, 如我这里是从github上tags里下载的1.4.1版本.
2.解压elasticsearch-analysis-ik-master.zip
unzip elasticsearch-analysis-ik-master.zip
3.进入elasticsearch-analysis-ik-master,编译源码
cd elasticsearch-analysis-ik-master
mvn clean install -Dmaven.test.skip=true
4.在$ES_HOME/plugins文件夹下创建analysis-ik
mkdir analysis-ik
5.将编译后生成的elasticsearch-analysis-ik-1.2.9.zip移到$ES_HOME/plugins/analysis-ik下,并解压。
编译后elasticsearch-analysis-ik-1.2.9.zip的生成位置
6.将config下的ik文件夹复制到$ES_HOME/config/下
7.修改$ES_HOME/config/elasticsearch.yml
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
#或
index.analysis.analyzer.ik.type : “ik”
8.重启Elasticsearch
二、测试
1.创建索引index
curl -XPUT http://localhost:9200/index
2.创建mapping
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": 8
}
}
}
}'
三、索引一些数据
curl -XPOST http://localhost:9200/index/fulltext/1 -d'
{"content":"东北大学是教育部直属的国家重点大学,坐落在东北中心城市沈阳。学校占地总面积261万平方米,建筑面积123万平方米。"}
'
curl -XPOST http://localhost:9200/index/fulltext/2 -d'
{"content":"东北大学在秦皇岛设立的分校。 东北大学秦皇岛分校是经教育部正式批准成立."}
'
curl -XPOST http://localhost:9200/index/fulltext/3 -d'
{"content":"东北大学秦皇岛分校是经教育部正式批准成立,在东北大学统一规划下,面向全国招生,相对独立办学的普通高等学校。学校始建于1987年,是东北大学的有机组成部分."}
'
curl -XPOST http://localhost:9200/index/fulltext/4 -d'
{"content":"东软 英文名称Neusoft,东软是中国领先的IT解决方案与服务供应商。1991年,东软创立于中国东北大学。公司主营业务包括:行业解决方案、产品工程解决方案及相关软件产品、平台及服务等。"}
'
curl -XPOST 'localhost:9200/index/fulltext/5' -d'{
"content":"作为中国最高学府,北京大学始终与国家民族的命运紧密相连,聚集了许多著名学者专家,培养了众多优秀人才,创造了大批重大科学成果,影响和推动了中国近现代思想理论、科学技术、文化教育和社会发展的进程。"
}'
curl -XPOST 'localhost:9200/index/fulltext/6' -d'{
"content":"改革开放后的北京大学(1976-至今)"
}'
curl -XPOST 'localhost:9200/index/fulltext/7' -d'
{"content":"香港大学(The University of Hong Kong),简称为港大(HKU),是一所位处中国香港特别行政区的公立研究型大学。其奠基于1910年3月16日[1] ,次年3月30日正式注册成立,是香港历史最悠久的高等教育机构。建校初期,香港大学规模极小,自1912年3月11日正式开学,到1916年12月举行首次毕业典礼,仅有23名毕业生。第二次世界大战爆发,香港大学一度处于瘫痪状态,1941年教学全面中止;1948年4月9日复校后,秩序重建与结构转型并举,学校步入高速发展的黄金时期。"}
'
四、查询
curl -XPOST http://localhost:9200/index/fulltext/_search -d'
{
"query" : { "term" : { "content" : "东北大学" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}
'
五、通过Kibana4.0进行数据可视化搜索
①首先修改配置,依次点击编辑按钮,如图所示:
②添加新的配置
把Index contains time-based events取消
在Index name of pattern内输入“index”,点击Create
③回到查询界面,选择index进行查询。
参考:https://github.com/medcl/elasticsearch-analysis-ik
- 为Elasticsearch安装中文分词IK
- 为Elasticsearch安装中文分词IK
- ElasticSearch中文分词ik安装
- ElasticSearch中文分词IK安装
- Elasticsearch安装中文分词插件ik
- Elasticsearch安装中文分词插件ik
- Elasticsearch安装中文分词插件ik
- Elasticsearch中文分词插件ik的安装
- Linux-CentOS Elasticsearch 安装ik中文分词
- Elasticsearch如何安装中文分词插件ik
- elasticsearch中文分词器IK安装
- Elasticsearch安装使用ik中文分词
- Elasticsearch如何安装中文分词插件ik
- Elasticsearch中文分词ik插件安装
- 安装Elasticsearch analysis ik中文分词插件
- Elasticsearch安装中文分词插件ik
- ElasticSearch IK中文分词器安装
- Elasticsearch安装ik分词
- 写入word
- windows上Apache+tomcat实现主备机服务器
- android 尺寸
- IEEE 802.15.4协议完整中文版 - 5.1.2.1 扫描信道
- HIVE 笔记
- 为Elasticsearch安装中文分词IK
- IntentFilter 匹配规则(网页中启动Activity)
- webmatrix
- PHP高级编程实例:编写守护进程
- IEEE 802.15.4协议完整中文版 - 5.1.2.2 PAN 标识符冲突的解决
- Android调试报错: 发现了以元素 'd:skin' 开头的无效内容。此处不应含有子元素。
- caffe的c++接口
- ThinkPHP模型当中的方法getField()很有意思
- dreamweaver快捷键