1,什么是分词器

分词器在ES 中,相当于字典一样,收录了很多的词。

但是,ElasticSearch 对中文的支持不是很大,默认的就是一个一个字,所以,我们需要安装插件比如IK 分词器,收录了几十万个词语。

 

2,默认的分词器,

中国好声音,没有一个词语,都一个个汉字

ElasticSearch 分词器

3,IK 安装

下载地址: https://github.com/medcl/elasticsearch-analysis-ik/releases

第一步:下载es的IK插件(资料中有)命名改为ik插件

第二步: 上传到/usr/local/elasticsearch-6.4.3/plugins

第三步: 重启elasticsearch即可

这样就可以出现中国汉语常用的词语几十万个了

 

4,自定义

由于一些新词,或者网络用语,IK 插件是没有收录的

也可以自定义

在/usr/local/elasticsearch-6.4.3/plugins/ik/config目录

 vi custom/new_word.dic 创建新词语,在

vi IKAnalyzer.cfg.xml 配置下就可以

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <comment>IK Analyzer 扩展配置</comment>
    <!--用户可以在这里配置自己的扩展字典 -->
    <entry key="ext_dict">custom/new_word.dic</entry>
     <!--用户可以在这里配置自己的扩展停止词字典-->
    <entry key="ext_stopwords"></entry>
    <!--用户可以在这里配置远程扩展字典 -->
    <!-- <entry key="remote_ext_dict">words_location</entry> -->
    <!--用户可以在这里配置远程扩展停止词字典-->
    <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
</properties>

ElasticSearch 分词器

相关文章:

  • 2022-12-23
  • 2021-04-17
  • 2021-10-22
  • 2021-08-02
  • 2021-12-08
  • 2021-09-28
  • 2021-06-14
  • 2022-02-04
猜你喜欢
  • 2021-12-07
  • 2021-09-24
  • 2021-10-23
  • 2021-11-24
  • 2021-07-18
相关资源
相似解决方案