安装ik分词插件
来源:互联网 发布:access数据库设计视图 编辑:程序博客网 时间:2024/06/14 20:44
下载IK安装包
https://github.com/medcl/elasticsearch-analysis-ik
https://github.com/medcl/elasticsearch-analysis-ik/releases
解压
tar –zxvf elasticsearch-analysis-ik-5.4.0.tar.gz
安装
拷贝elasticsearch-analysis-ik-5.4.0文件夹到
elasticsearch-5.4.0/plugins目录下
重启
重启elasticsearch
测试ik分词器
生成索引
PUT test
测试细粒度的分词
GET test/_analyze?analyzer=ik_max_word{ "text":"武汉市长江大桥"}
返回值
{ "tokens": [ { "token": "武汉市", "start_offset": 0, "end_offset": 3, "type": "CN_WORD", "position": 0 }, { "token": "武汉", "start_offset": 0, "end_offset": 2, "type": "CN_WORD", "position": 1 }, { "token": "市长", "start_offset": 2, "end_offset": 4, "type": "CN_WORD", "position": 2 }, { "token": "长江大桥", "start_offset": 3, "end_offset": 7, "type": "CN_WORD", "position": 3 }, { "token": "长江", "start_offset": 3, "end_offset": 5, "type": "CN_WORD", "position": 4 }, { "token": "大桥", "start_offset": 5, "end_offset": 7, "type": "CN_WORD", "position": 5 } ]}
测试粗粒度的分词
GET test/_analyze?analyzer=iksmart{ "text":"武汉市长江大桥"}
只返回了两个词
{ "tokens": [ { "token": "武汉市", "start_offset": 0, "end_offset": 3, "type": "CN_WORD", "position": 0 }, { "token": "长江大桥", "start_offset": 3, "end_offset": 7, "type": "CN_WORD", "position": 1 } ]}
测试ik分词器官方实例
语法是curl的方式,粘贴到kibana后会自动生成restful方式的查询dsl
- create a index
curl -XPUT http://localhost:9200/index
- create a mapping
curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'{ "properties": { "content": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" } }}'
3.index some docs
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.query with highlighting
高亮查询,会在返回的匹配关键词前后加上pre_tags、post_tags里的内容
curl -XPOST http://localhost:9200/index/fulltext/_search -d'{ "query" : { "match" : { "content" : "中国" }}, "highlight" : { "pre_tags" : ["<tag1>", "<tag2>"], "post_tags" : ["</tag1>", "</tag2>"], "fields" : { "content" : {} } }}'
返回的结果中命中的关键会加上pretags 和post_tags
{ "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
- 安装ik分词插件
- ElasticSearch安装ik分词插件
- ElasticSearch安装ik分词插件
- ElasticSearch 安装 ik 分词插件
- ElasticSearch安装ik分词插件
- ElasticSearch安装ik分词插件
- Elasticsearch安装中文分词插件ik
- Elasticsearch安装中文分词插件ik
- Elasticsearch安装中文分词插件ik
- Elasticsearch中文分词插件ik的安装
- elasticsearch的IK分词插件安装
- Elasticsearch如何安装中文分词插件ik
- Elasticsearch2.3.1中文分词ik插件安装
- Elasticsearch如何安装中文分词插件ik
- Elasticsearch安装分词插件IK及问题解决
- Elasticsearch之安装ik分词插件
- elastic笔记:ik分词插件安装
- Elasticsearch中文分词ik插件安装
- 2018 京东笔试疯狂序列
- Windows 下配置Tensorflow
- 关于我的第一个爬虫--Python+selenium+parsel+动态网页
- Hibernate入门(7):HQL查询
- 欢迎使用CSDN-markdown编辑器
- 安装ik分词插件
- WOJ-294 数老鼠
- Java之反射机制
- Jquery easyui 将前台数据进行转换
- 卷积神经网络新思路
- Hibernate入门(8):SQL查询
- 机器学习:手写数字识别(Hand-written digits recognition)小项目
- windows网络编程 实现域名查询ip
- 基于TF-IDF的酒店名称模糊匹配