溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

安裝elasticsearch-analysis-ik中文分詞器的步驟講解

發(fā)布時(shí)間:2020-09-15 16:50:22 來源:腳本之家 閱讀:243 作者:toto1297488504 欄目:編程語言

1 安裝elasticsearch-analysis-ik中文分詞器

Ik介紹:ik是一款中文的分詞插件,支持自定義詞庫。

1.1 下載ik分詞器

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

下載指定版本的分詞器(zip版本)

1.2 解壓ik分詞器

[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 重新啟動(dòng)Elasticsearch服務(wù)

ps -ef | grep elasticsearch
然后kill掉相關(guān)的進(jìn)程。
然后按照18.8的方式啟動(dòng)elasticsearch進(jìn)程

1.4 然后執(zhí)行以下命令

GET _analyze 
{ 
 "analyzer":"ik_smart", 
 "text":"2018年5月全球編程語言排行榜" 
}

運(yùn)行結(jié)果是:

{
  "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中文分詞器的步驟講解

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對億速云的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI