二、Elastic5.5.2安装中文分词器教程及简单测试
来源:互联网 发布:豆腐软件 编辑:程序博客网 时间:2024/05/17 22:29
一、下载分词器安装包
首先进入各版本下载页面,选择相应的版本进行下载(和自己安装的ElasticSearch版本保持一致)。我这里安装的是5.5.2的ElasticSearch,所以选择对应的5.5.2软件包。
右键·复制下载链接·,在Linux系统中使用wget命令下载
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.2/elasticsearch-analysis-ik-5.5.2.zip
这一步有时候会下载不成功,那么可以使用浏览器本地电脑下载完成后,使用工具上传到服务器目录中。
二、解压并安装
1.移动elasticsearch-analysis-ik-5.5.2.zip到安装目录的plugins目录
[king@localhost soft]$ mv elasticsearch-analysis-ik-5.5.2.zip /soft/elasticsearch-5.5.2/plugins/
2.进入安装目录的plugins目录
[king@localhost soft]$ cd /soft/elasticsearch-5.5.2/plugins/[king@localhost plugins]$ lselasticsearch-analysis-ik-5.5.2.zip x-pack
3.解压
[king@localhost plugins]$ unzip elasticsearch-analysis-ik-5.5.2.zip [king@localhost plugins]$ lselasticsearch elasticsearch-analysis-ik-5.5.2.zip x-pack
4.删除压缩包(非必须)
[king@localhost plugins]$ rm -rf elasticsearch-analysis-ik-5.5.2.zip
按照官方说明,这时已经成功安装了,重启ElasticSearch即可。
三、测试
1.创建一个索引
curl -XPUT http://localhost:9200/index
2.创建一个映射
curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'{ "properties": { "content": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" } }}'
3.索引一些文档,可以认为就是插入一些信息
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":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'
4.查询,结果以高亮显示
查询
curl -XPOST http://localhost:9200/index/fulltext/_search -d'{ "query" : { "match" : { "content" : "中国" }}, "highlight" : { "pre_tags" : ["<tag1>", "<tag2>"], "post_tags" : ["</tag1>", "</tag2>"], "fields" : { "content" : {} } }}'
结果
{ "took": 14, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 2, "max_score": 2, "hits": [ { "_index": "index", "_type": "fulltext", "_id": "4", "_score": 2, "_source": { "content": "中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首" }, "highlight": { "content": [ "<tag1>中国</tag1>驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首 " ] } }, { "_index": "index", "_type": "fulltext", "_id": "3", "_score": 2, "_source": { "content": "中韩渔警冲突调查:韩警平均每天扣1艘中国渔船" }, "highlight": { "content": [ "均每天扣1艘<tag1>中国</tag1>渔船 " ] } } ] }}
阅读全文
0 0
- 二、Elastic5.5.2安装中文分词器教程及简单测试
- SOLR安装及中文分词
- solr 6.2.0系列教程(二)IK中文分词器配置及添加扩展词、停止词、同义词
- Luence 4.4 Jcseg中文分词简单测试
- elastic5.2.1安装
- 安装elasticsearch及中文分词器、客户端连接示例
- elasticsearch安装配置及中文分词
- elasticsearch安装配置及中文分词
- elasticsearch安装配置及中文分词
- elasticsearch安装配置及中文分词
- solr 5.3.2 安装及中文分词
- 中文分词器安装配置
- 安装中文分词器 IKAnalyzer
- 中文分词测试
- 中文分词测试集
- 四款python中文分词系统简单测试
- 中文分词笔记之三:示例代码及测试结果
- 安装中文分词器。solr集成ikanalyzer分词器
- Java Arrays.asList注意事项
- UVA 297
- 【笔记】Python学习笔记 ——1
- PHP加密方法
- CentOS 7 yum 安装 Nginx
- 二、Elastic5.5.2安装中文分词器教程及简单测试
- UVA 712
- 自写过滤器替代ValidateAntiForgeryToken解决asp.net mvc关于提供的防伪标记适用于其他基于声明的用户,而不适用于当前用户的错误
- 科研助手
- [hdu-1512]Monkey King 题解
- 篇启
- Java里一些容易混淆的概念
- 图片和Canvas的相互转换
- 2.数据挖掘简介