下载

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-analysis-ik-6.4.5.zip 下载都解压到了Dockerfile同目录下的elasticsearch-analysis-ik-6.4.5目录中,然后通过ADD指令将elasticsearch-analysis-ik-6.4.5目录拷贝到了docker中elasticsearch的plugins目录。

ElasticSearch 中文分词插件ik 的使用的更多相关文章

  1. ElasticSearch(三) ElasticSearch中文分词插件IK的安装

    正因为Elasticsearch 内置的分词器对中文不友好,会把中文分成单个字来进行全文检索,所以我们需要借助中文分词插件来解决这个问题. 一.安装maven管理工具 Elasticsearch 要使 ...

  2. ElasticSearch(四) ElasticSearch中文分词插件IK的简单测试

    先来一个简单的测试 # curl -XPOST "http://192.168.9.155:9200/_analyze?analyzer=standard&pretty" ...

  3. Elasticsearch安装中文分词插件ik

    Elasticsearch默认提供的分词器,会把每一个汉字分开,而不是我们想要的依据关键词来分词.比如: curl -XPOST "http://localhost:9200/userinf ...

  4. Elasticsearch如何安装中文分词插件ik

    elasticsearch-analysis-ik 是一款中文的分词插件,支持自定义词库. 安装步骤: 1.到github网站下载源代码,网站地址为:https://github.com/medcl/ ...

  5. ElasticSearch中文分词(IK)

    ElasticSearch常用的很受欢迎的是IK,这里稍微介绍下安装过程及测试过程.   1.ElasticSearch官方分词 自带的中文分词器很弱,可以体检下: [zsz@VS-zsz ~]$ c ...

  6. ElasticSearch-5.0.0安装中文分词插件IK

    Install IK 源码地址:https://github.com/medcl/elasticsearch-analysis-ik,git clone下来. 1.compile mvn packag ...

  7. ElasticSearch中文分词器-IK分词器的使用

    IK分词器的使用 首先我们通过Postman发送GET请求查询分词效果 GET http://localhost:9200/_analyze { "text":"农业银行 ...

  8. Elasticsearch 中文分词器IK

    1.安装说明 https://github.com/medcl/elasticsearch-analysis-ik 2.release版本 https://github.com/medcl/elast ...

  9. ElasticSearch搜索引擎安装配置中文分词器IK插件

    近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...

随机推荐

  1. CSS3 transform属性

    说明: transform 属性向元素应用 2D 或 3D 转换.该属性允许我们对元素进行移动(translate).旋转(rotate).缩放(scale)或倾斜(skew) transition属 ...

  2. 利用python爬虫关键词批量下载高清大图

    前言 在上一篇写文章没高质量配图?python爬虫绕过限制一键搜索下载图虫创意图片!中,我们在未登录的情况下实现了图虫创意无水印高清小图的批量下载.虽然小图能够在一些移动端可能展示的还行,但是放到pc ...

  3. bugku—Web_Writeup

    Bugku_Web_Writeup Writeup略显粗糙~~ 部分Web题没有得到最后的flag~只是有了一个简单的思路~~ Web1: 如上,打开题目答题网址后就会弹出一张图片,看图片就可以发现是 ...

  4. apache中通过mod_rewrite实现伪静态页面的方法

    rewrite规则学习 我们新建一个.htaccess文件之后,就在里面写入以下内容: RewriteEngine on #rewriteengine为重写引擎开关on为开启off为关闭 Rewrit ...

  5. Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用

    Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用 1. 引言 在上一篇文章<Spring Boot (九): 微服务应用监控 Spring ...

  6. [UWP] 解决FlipView图片放大的诡异bug

    想要实现图片的放大缩小可以通过在Image外面套一个ScrollViewer,然后设置ScrollViewer的ZoomMode="Enabled" <FlipView It ...

  7. JAVA错误提示:The operation is not applicable to the current selection.Select a field which is not declared as type variable or a type that declares such fields.

    平时没怎么注意,今天用Eclipse自动生成Set Get方法时提示错误,错误信息如下: The operation is not applicable to the current selectio ...

  8. Android开发——实现子线程更新UI

    Android中线程按功能分的话,可以分为两个,一个是主线程(UI线程),其他的都是子线程 主线程不能执行那些耗时过长的代码或任务(执行耗时过长的代码会出现应用未响应的提示),所以都是使用子线程来执行 ...

  9. 关于未来实现API管理系统的几个关键词

    下面将通过几个关键词的形式说明API管理的重要性和未来的实现方式. 1.生命周期管理 在整个API生命周期中更深入地集成所有工具将进一步提高生命周期循环的速度,而且更重要的是提供满足消费者需求的API ...

  10. python程序编译成exe文件

    最近越来越喜欢使用python写工具.使用的时候,发现程序内部成员python安装目录常常不同,如果用bat双击执行,常常需要修改从svn上down下来的bat文件中python.exe的路径.而给策 ...