服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - 安装elasticsearch-analysis-ik中文分词器的步骤讲解

安装elasticsearch-analysis-ik中文分词器的步骤讲解

2021-07-15 14:52toto1297488504 Java教程

今天小编就为大家分享一篇关于安装elasticsearch-analysis-ik中文分词器的步骤讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧

1 安装elasticsearch-analysis-ik中文分词器

ik介绍:ik是一款中文的分词插件,支持自定义词库。

1.1 下载ik分词器

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

下载指定版本的分词器(zip版本)

1.2 解压ik分词器

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[es@bigdata1 plugins]$ cd /home/es/
[es@bigdata1 ~]$ ls
elasticsearch-6.2.2         jdk1.8.0_161        kibana-6.2.2-linux-x86_64.tar.gz
elasticsearch-6.2.2.tar.gz      jdk-8u161-linux-x64.tar.gz logstash-6.2.2.tar.gz
elasticsearch-analysis-ik-6.2.2.zip kibana-6.2.2-linux-x86_64
[es@bigdata1 ~]$ unzip elasticsearch-analysis-ik-6.2.2.zip
archive: elasticsearch-analysis-ik-6.2.2.zip
  creating: elasticsearch/
 inflating: elasticsearch/elasticsearch-analysis-ik-6.2.2.jar
 inflating: elasticsearch/httpclient-4.5.2.jar
 inflating: elasticsearch/httpcore-4.4.4.jar
 inflating: elasticsearch/commons-logging-1.2.jar
 inflating: elasticsearch/commons-codec-1.9.jar
 inflating: elasticsearch/plugin-descriptor.properties
  creating: elasticsearch/config/
 inflating: elasticsearch/config/extra_single_word_full.dic
 inflating: elasticsearch/config/quantifier.dic
 inflating: elasticsearch/config/ikanalyzer.cfg.xml
 inflating: elasticsearch/config/main.dic
 inflating: elasticsearch/config/extra_single_word_low_freq.dic
 inflating: elasticsearch/config/extra_stopword.dic
 inflating: elasticsearch/config/preposition.dic
 inflating: elasticsearch/config/extra_main.dic
 inflating: elasticsearch/config/extra_single_word.dic
 inflating: elasticsearch/config/suffix.dic
 inflating: elasticsearch/config/surname.dic
 inflating: elasticsearch/config/stopword.dic
[es@bigdata1 ~]$ ls
elasticsearch        elasticsearch-analysis-ik-6.2.2.zip kibana-6.2.2-linux-x86_64
elasticsearch-6.2.2     jdk1.8.0_161             kibana-6.2.2-linux-x86_64.tar.gz
elasticsearch-6.2.2.tar.gz jdk-8u161-linux-x64.tar.gz      logstash-6.2.2.tar.gz
[es@bigdata1 ~]$ mv elasticsearch/* ./elasticsearch-6.2.2/plugins/ik/
[es@bigdata1 ~]$ vim ./elasticsearch-6.2.2/config/elasticsearch.yml

1.3 重新启动elasticsearch服务

ps -ef | grep elasticsearch
然后kill掉相关的进程。
然后按照18.8的方式启动elasticsearch进程

1.4 然后执行以下命令

?
1
2
3
4
5
get _analyze
{
 "analyzer":"ik_smart",
 "text":"2018年5月全球编程语言排行榜"
}

运行结果是:

{
  "tokens": [
    {
      "token": "2018年",
      "start_offset": 0,
      "end_offset": 5,
      "type": "type_cquan",
      "position": 0
    },
    {
      "token": "5月",
      "start_offset": 5,
      "end_offset": 7,
      "type": "type_cquan",
      "position": 1
    },
    {
      "token": "全球",
      "start_offset": 7,
      "end_offset": 9,
      "type": "cn_word",
      "position": 2
    },
    {
      "token": "编程",
      "start_offset": 9,
      "end_offset": 11,
      "type": "cn_word",
      "position": 3
    },
    {
      "token": "语言",
      "start_offset": 11,
      "end_offset": 13,
      "type": "cn_word",
      "position": 4
    },
    {
      "token": "排行榜",
      "start_offset": 13,
      "end_offset": 16,
      "type": "cn_word",
      "position": 5
    }
  ]
}

kibana的效果图

安装elasticsearch-analysis-ik中文分词器的步骤讲解

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。如果你想了解更多相关内容请查看下面相关链接

原文链接:https://blog.csdn.net/tototuzuoquan/article/details/80782476

延伸 · 阅读

精彩推荐