1、環境同上篇文章
2、使用ElasticSearch-plugin安裝
cd kibana-6.2.2
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.0/elasticsearch-analysis-ik-6.2.0.zip
3、查看安裝目錄
ll plugins/analysis-ik/
# 顯示如下內容
total 1420
-rw-r--r--. 1 root root 263965 May 13 09:21 commons-codec-1.9.jar
-rw-r--r--. 1 root root 61829 May 13 09:21 commons-logging-1.2.jar
-rw-r--r--. 1 root root 52572 May 13 09:21 elasticsearch-analysis-ik-6.2.2.jar
-rw-r--r--. 1 root root 736658 May 13 09:21 httpclient-4.5.2.jar
-rw-r--r--. 1 root root 326724 May 13 09:21 httpcore-4.4.4.jar
-rw-r--r--. 1 root root 1805 May 13 09:21 plugin-descriptor.properties
4、測試
image.png
5、自定義詞典
cd config/analysis-ik
mkdir custom
vi custom/new_word.dic
# 添加“學習強國”
cat custom/new_word.dic
學習強國
6、更新配置
vim IKAnalyzer.cfg.xml
image.png
4、重啓elasticsearch,測試
image.png
ik 帶有兩個分詞器
ik_max_word :會將文本做最細粒度的拆分;儘可能多的拆分出詞語
ik_smart:會做最粗粒度的拆分;已被分出的詞語將不會再次被其它詞語佔有
ik_max_word,這種分詞會把詞句分爲最小和各種組合:
舉例:我想去少年宮
分詞是: 我,想,去,少,年,宮
用戶查找的時候,輸入任何一個包含的詞句都會查找的到記錄,
使用ik_smart: 會分詞:想去,少年宮
用戶輸入 少年,會查不到記錄。
作者:境與界
鏈接:https://www.jianshu.com/p/0b6627ed70df
來源:簡書
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。