【ES插件】analysis-icu和analysis-kuromoji

《ES analysis-icu插件》

一、analysis-icu插件簡介

ICU Analysis Plugin組織結構
ICU - International Components for Unicode
Elasticsearch的ICU 分析器插件使用國際化組件 Unicode (ICU) 函數庫(詳情查看 site.project.org)提供豐富的處理 Unicode 工具。 這些包含對處理亞洲語言特別有用的 icu_分詞器 ,還有大量對除英語外其他語言進行正確匹配和排序所必須的分詞過濾器。

注意事項

ICU 插件是處理英語之外語言的必需工具,非常推薦你安裝並使用它,不幸的是,因爲是基於額外的 ICU 函數庫, 不同版本的ICU插件可能並不兼容之前的版本,當更新插件的時候,你需要重新索引你的數據

icu_分詞器

  1. icu_分詞器 和 標準分詞器 使用同樣的 Unicode 文本分段算法, 只是爲了更好的支持亞洲語,添加了泰語、老撾語、中文、日文、和韓文基於詞典的詞彙識別方法,並且可以使用自定義規則將緬甸語和柬埔寨語文本拆分成音節。
  2. 相較而言, 標準分詞器 分詞中文和日文的時候“過度分詞”了,經常將一個完整的詞拆分爲獨立的字符,因爲單詞之間並沒有空格,很難區分連續的字符是間隔的單詞還是一個句子中的單字。
  3. 雖然每個字符本身可以是一個單詞,但使詞彙單元保持更大的原始概念比使其僅作爲一個詞組的一部分要有意義的多:
  • 標準分詞器在下面的例子中將每個字符輸出爲單獨的詞彙單元: 向 , 日 , 葵 。
  • icu_分詞器則會輸出單個詞彙單元:向日葵 (sunflower) 。

GET /_analyze?tokenizer=standard
向日葵

GET /_analyze?tokenizer=icu_tokenizer
向日葵

二、安裝analysis-icu

可以通過plugin manager安裝:

sudo bin/elasticsearch-plugin install analysis-icu

如果你有很多節點並以集羣方式運行的,你需要在集羣的每個節點都安裝這個插件,每個節點安裝完成後都需要重啓才能生效。

三、卸載analysis-icu

在卸載icu插件之前,必須先停止節點,再通過以下命令進行移除:

sudo bin/elasticsearch-plugin remove analysis-icu

*######################################## 分割線 ######################################## *

《ES analysis-kuromoji插件》

  1. Introduction
    The kuromoji_tokenizer accepts the following settings:
    mode
    discard_punctuation
    user_dictionary
    nbest_cost/nbest_examples

來看看mode參數
The tokenization mode determines how the tokenizer handles compound and unknown words. It can be set to:

  • normal
    Normal segmentation, no decomposition for compounds. Example output:
    関西國際空港
    アブラカダブラ
  • search
    Segmentation geared towards search. This includes a decompounding process for long nouns, also including the full compound token as a synonym. Example output:
    関西, 関西國際空港, 國際, 空港
    アブラカダブラ
  • extended
    Extended mode outputs unigrams for unknown words. Example output:
    関西, 國際, 空港
    ア, ブ, ラ, カ, ダ, ブ, ラ
  1. Installation
    This plugin can be installed using the plugin manager:

sudo bin/elasticsearch-plugin install analysis-kuromoji

The plugin must be installed on every node in the cluster, and each node must be restarted after installation.

This plugin can be downloaded for offline install from
https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-kuromoji/analysis-kuromoji-6.7.2.zip.

  1. Removal
    The plugin can be removed with the following command:

sudo bin/elasticsearch-plugin remove analysis-kuromoji

The node must be stopped before removing the plugin.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章