在命令行创建install.sh脚本,并将以下内容贴进去:
#!/bin/bash
# 高升前端代码发布脚本
set -e
export LANG=zh_CN.UTF-8
#下载es7.15.1版本
wget https://mirrors.huaweicloud.com/elasticsearch/7.15.1/elasticsearch-7.15.1-x86_64.rpm
#下载es7.17.7版本
#wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.7-x86_64.rpm
#安装Es
#rpm --install elasticsearch-7.17.7-x86_64.rpm
rpm --install elasticsearch-7.15.1-x86_64.rpm
#进度插件目录
cd /usr/share/elasticsearch/plugins
#创建插件目录
mkdir es_ik
cd es_ik
#下载Ik分词插件
#wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.15.1/elasticsearch-analysis-ik-7.15.1.zip
#解压插件
#unzip elasticsearch-analysis-ik-7.17.7.zip
unzip elasticsearch-analysis-ik-7.15.1.zip
#重新启动ES
systemctl restart elasticsearch.service
#测试分词
curl -XPOST "localhost:9200/_analyze" -H 'Content-Type: application/json' -d'
{
"analyzer": "ik_smart",
"text": "中国和韩国"
}'
在命令行执行安装:
bash install.sh
然后会看到如下测试输出,则表示es和ik分词都已经安装完毕:
{"tokens":[{"token":"中国","start_offset":0,"end_offset":2,"type":"CN_WORD","position":0},{"token":"和","start_offset":2,"end_offset":3,"type":"CN_CHAR","position":1},{"token":"韩国","start_offset":3,"end_offset":5,"type":"CN_WORD","position":2}]}
附录:
华为ES镜像地址:Index of elasticsearch-local
IK分词组件版本下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases