ElasticSearch 中文分词插件ik 的使用

下载
IK 的版本要与 Elasticsearch 的版本一致,因此下载 7.1.0 版本。
安装
1、中文分词插件下载地址:https://github.com/medcl/elasticsearch-analysis-ik
2、拼音分词插件下载地址:https://github.com/medcl/elasticsearch-analysis-pinyin
下载你对应的版本


将解压后的 IK 文件夹,放入 elasticsearch 文件夹下的 plugins/ik 目录下。
启动 Elasticsearch 后,看到下图,表示启动成功。

扩展本地词库
在 plugins\ik\config\custom 目录下新增文件 hotwords.dic。如添加 洪荒之力 。每一个词语一行。
在 plugins\ik\config 文件夹下的 IKAnalyzer.cfg.xml 文件配置本地词库。
<!--用户可以在这里配置自己的扩展字典,如果多个字典,则用分号分隔 custom/mydict.dic;custom/single_word_low_freq.dic-->
<entry key="ext_dict">custom/hotwords.dic</entry>
重新启动 Elasticsearch 显示如下图,表示启动成功。

文档的中文分词使用
IK分词器有两种分词模式:ik_max_word和ik_smart模式。
1、ik_max_word
会将文本做最细粒度的拆分,比如会将“中华人民共和国人民大会堂”拆分为“中华人民共和国、中华人民、中华、华人、人民共和国、人民、共和国、大会堂、大会、会堂等词语。
2、ik_smart
会做最粗粒度的拆分,比如会将“中华人民共和国人民大会堂”拆分为中华人民共和国、人民大会堂。
下面我们分别测试下。
先测试ik_max_word,输入命令如下:
POST http://localhost:9200/_analyze
{
"analyzer": "ik_max_word",
"text": "世界如此之大"
}
响应结果如下:
{
"tokens": [
{
"token": "世界",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
},
{
"token": "如此之",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
},
{
"token": "如此",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
},
{
"token": "之大",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
}
]
}
再测试ik_smart,输入命令如下:
POST http://localhost:9200/_analyze
{
"analyzer": "ik_smart",
"text": "世界如此之大"
}
响应结果如下:
{
"tokens": [
{
"token": "世界",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
},
{
"token": "如此",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
},
{
"token": "之大",
"start_offset": ,
"end_offset": ,
"type": "CN_WORD",
"position":
}
]
}
通过Docker 安装elasticsearch-analysis-ik-6.4.5插件
FROM docker.elastic.co/elasticsearch/elasticsearch:6.4.5
ADD elasticsearch-analysis-ik-6.4.5 /usr/share/elasticsearch/plugins/elasticsearch-analysis-ik-6.4.5
ElasticSearch 中文分词插件ik 的使用的更多相关文章
- ElasticSearch(三) ElasticSearch中文分词插件IK的安装
正因为Elasticsearch 内置的分词器对中文不友好,会把中文分成单个字来进行全文检索,所以我们需要借助中文分词插件来解决这个问题. 一.安装maven管理工具 Elasticsearch 要使 ...
- ElasticSearch(四) ElasticSearch中文分词插件IK的简单测试
先来一个简单的测试 # curl -XPOST "http://192.168.9.155:9200/_analyze?analyzer=standard&pretty" ...
- Elasticsearch安装中文分词插件ik
Elasticsearch默认提供的分词器,会把每一个汉字分开,而不是我们想要的依据关键词来分词.比如: curl -XPOST "http://localhost:9200/userinf ...
- Elasticsearch如何安装中文分词插件ik
elasticsearch-analysis-ik 是一款中文的分词插件,支持自定义词库. 安装步骤: 1.到github网站下载源代码,网站地址为:https://github.com/medcl/ ...
- ElasticSearch中文分词(IK)
ElasticSearch常用的很受欢迎的是IK,这里稍微介绍下安装过程及测试过程. 1.ElasticSearch官方分词 自带的中文分词器很弱,可以体检下: [zsz@VS-zsz ~]$ c ...
- ElasticSearch-5.0.0安装中文分词插件IK
Install IK 源码地址:https://github.com/medcl/elasticsearch-analysis-ik,git clone下来. 1.compile mvn packag ...
- ElasticSearch中文分词器-IK分词器的使用
IK分词器的使用 首先我们通过Postman发送GET请求查询分词效果 GET http://localhost:9200/_analyze { "text":"农业银行 ...
- Elasticsearch 中文分词器IK
1.安装说明 https://github.com/medcl/elasticsearch-analysis-ik 2.release版本 https://github.com/medcl/elast ...
- ElasticSearch搜索引擎安装配置中文分词器IK插件
近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...
随机推荐
- MySQL 分页查询优化
有时在处理偏移量非常大的分页时候查询时,例如LIMIT 1000,10这样的查询,这时MySQL需要查询1010条记录然后只返回最后10条,前面1000条记录都被抛弃,这样的代价非常高.要优化这种查询 ...
- Java 文章链接
Java表单验证封装类 https://www.cnblogs.com/linjiqin/archive/2013/11/18/3429424.html 微信企业号接入JDK6和JDK7及JDK8加解 ...
- springboot结合mybatis使用pageHelper插件进行分页查询
1.pom相关依赖引入 <dependencies> <dependency> <groupId>org.springframework.boot</grou ...
- ThinkPHP5实现定时任务
ThinkPHP5实现定时任务 最近使用ThinkPHP5做了个项目,项目中需要定时任务的功能,感觉有必要分享下 TP5做定时任务使用到command.php的 步骤如下: 1.配置command.p ...
- v-text和v-html的区别
一.v-text 用于渲染普通文本,无论何时,绑定的数据对象上 msg属性发生了改变,插值处的内容都会更新. <span v-text="message"></s ...
- [ngclass]、[ngstyle]、管道
[ngclass] 动态改变一个元素的class ts: public classcolor:boolean=false; public list:any = [{title:"新闻1&qu ...
- word2vec预训练词向量
NLP中的Word2Vec讲解 word2vec是Google开源的一款用于词向量计算 的工具,可以很好的度量词与词之间的相似性: word2vec建模是指用CBoW模型或Skip-gram模型来计算 ...
- display值的作用分别是什么?relative和absolute分别是相对谁定位的?
display值的作用分别是什么? none:元素隐藏,不占据位置 block:该元素显示为块级元素 inline:默认,该元素会被显示为内联元素 inline-block:行内块元素 list-it ...
- MySQLdb操作数据库
堡垒机前戏 开发堡垒机之前,先来学习Python的paramiko模块,该模块机遇SSH用于连接远程服务器并执行相关操作 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接: + ...
- B-经济学-基尼指数
目录 基尼指数 一.基尼指数简介 更新.更全的<机器学习>的更新网站,更有python.go.数据结构与算法.爬虫.人工智能教学等着你:https://www.cnblogs.com/ni ...