ElasticSearch 安装IK分词器
生活随笔
收集整理的這篇文章主要介紹了
ElasticSearch 安装IK分词器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 1,ES安裝ik分詞器
- 2,測試使用
1,ES安裝ik分詞器
IK分詞器下載參考:https://gitcode.net/mirrors/medcl/elasticsearch-analysis-ik
#1. ES安裝IK分詞器:ES版本:5.4.3 == IK分詞器版本:5.4.3 # ES-IK分詞器下載:https://github.com/medcl/elasticsearch-analysis-ik/releases?page=12 # https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.4.3/elasticsearch-analysis-ik-5.4.3.zip#查看ES版本 [root@daas4 ~]# curl localhost:9200 {"name" : "daas4","cluster_name" : "dass-es","cluster_uuid" : "D89bKW29TlyGul9qELxXwQ","version" : {"number" : "5.4.3","build_hash" : "eed30a8","build_date" : "2017-06-22T00:34:03.743Z","build_snapshot" : false,"lucene_version" : "6.5.1"},"tagline" : "You Know, for Search" }#離線安裝plugin [root@daas4 elasticsearch-5.4.3]# cd plugins/ [root@daas4 plugins]# mkdir ik ; ls ik [root@daas4 plugins]# unzip ../elasticsearch-analysis-ik-5.4.3.zip -d ik/ Archive: ../elasticsearch-analysis-ik-5.4.3.zipinflating: ik/plugin-descriptor.properties creating: ik/config/creating: ik/config/custom/inflating: ik/config/custom/ext_stopword.dic inflating: ik/config/custom/mydict.dic inflating: ik/config/custom/single_word.dic inflating: ik/config/custom/single_word_full.dic inflating: ik/config/custom/single_word_low_freq.dic inflating: ik/config/custom/sougou.dic inflating: ik/config/IKAnalyzer.cfg.xml inflating: ik/config/main.dic inflating: ik/config/preposition.dic inflating: ik/config/quantifier.dic inflating: ik/config/stopword.dic inflating: ik/config/suffix.dic inflating: ik/config/surname.dic inflating: ik/elasticsearch-analysis-ik-5.4.3.jar inflating: ik/httpclient-4.5.2.jar inflating: ik/httpcore-4.4.4.jar inflating: ik/commons-logging-1.2.jar inflating: ik/commons-codec-1.9.jar [root@daas4 plugins]# /export/server/elasticsearch-5.4.3/bin/elasticsearch-plugin list elasticsearch ik[root@daas4 plugins]# ll ik/ total 1424 -rw-r--r-- 1 root root 263965 Dec 16 15:51 commons-codec-1.9.jar -rw-r--r-- 1 root root 61829 Sep 13 09:36 commons-logging-1.2.jar drwxr-xr-x 3 root root 4096 Jul 1 2017 config -rw-r--r-- 1 root root 51409 Dec 16 16:12 elasticsearch-analysis-ik-5.4.3.jar -rw-r--r-- 1 root root 736658 Sep 13 09:46 httpclient-4.5.2.jar -rw-r--r-- 1 root root 326724 Dec 16 15:51 httpcore-4.4.4.jar -rw-r--r-- 1 root root 2666 Dec 16 16:12 plugin-descriptor.properties2,測試使用
#2. 測試ik分詞 [root@daas4 plugins]# curl -XPOST http://localhost:9200/_analyze?pretty -H 'Content-Type:application/json' -d ' { "analyzer": "ik_max_word","text": "我們是中國人" }'result===> {"tokens" : [{"token" : "我們","start_offset" : 0,"end_offset" : 2,"type" : "CN_WORD","position" : 0},{"token" : "中國人","start_offset" : 3,"end_offset" : 6,"type" : "CN_WORD","position" : 1},{"token" : "中國","start_offset" : 3,"end_offset" : 5,"type" : "CN_WORD","position" : 2},{"token" : "國人","start_offset" : 4,"end_offset" : 6,"type" : "CN_WORD","position" : 3}] }#3. 創建索引,指定字段解析器和類型 [root@daas4 plugins]# curl -XPUT localhost:9200/test_ik?pretty -H "Content-Type: application/json" -d ' {"mappings": {"_default_": {"_all": {"enabled": false},"properties": {"tableSuffix": {"index": true,"store": true,"type": "keyword"},"databaseName": {"search_analyzer": "ik_max_word","analyzer": "ik_max_word","index": true,"store": true,"type": "text"},"tableId": {"index": true,"store": true,"type": "keyword"}}}} }'result==> {"acknowledged" : true,"shards_acknowledged" : true }[root@daas4 plugins]# curl localhost:9200/_cat/indices?v health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open test10 uX9kL6HzRL-jrwdbaKmd5Q 5 1 0 0 795b 795b yellow open test_ik JLNthJcmQQO1416Td4ldUQ 5 1 0 0 650b 650b總結
以上是生活随笔為你收集整理的ElasticSearch 安装IK分词器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: qtgl 鼠标平移 c++_罗技真爱粉的
- 下一篇: 计算机仿真技术-基于matlab的电子信