Elasticsearch搭建

下載安裝Elasticsearch

下載地址:https://www.elastic.co/cn/downloads/elasticsearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz

解壓:

 tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz 

給非root用戶給予權限:

 chown -R 文件夾名 用戶名

啓動:

./bin/elasticsearch
./bin/elasticsearch -d #後臺運行

測試查看是否啓動成功:

curl localhost:9200

安裝ik分詞器

https://github.com/medcl/elasticsearch-analysis-ik

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.4.2/elasticsearch-analysis-ik-7.4.2.zip

如果報錯

進入/etc/resolv.conf。
修改內容爲下
nameserver 8.8.8.8 #google域名服務器
nameserver 8.8.4.4 #google域名服務器

解壓

cd plugins/
mkdir ik
cd ik
unzip elasticsearch-analysis-ik-7.4.2.zip 

重啓後測試:

curl -XGET -H "Content-Type: application/json"  "http://localhost:9200/_analyze?pretty=true" -d'{"text":"公安部:各地校車將享最高路權"}';

curl -XGET -H "Content-Type: application/json"  "http://localhost:9200/_analyze?pretty=true" -d'{"text":"公安部:各地校車將享最高路權","analyzer": "ik_max_word"}';

OK~~~更多內容請查看官網:

https://www.elastic.co/guide/cn/index.html

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