1、安装maven
安装插件前,需要用 maven 进行编译生成插件包,第一步先安装 maven
yum install -y maven
mvn -version Apache Maven 3.0.5 (Red Hat 3.0.5-17) Maven home: /usr/share/maven Java version: 1.8.0_222, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-957.27.2.el7.x86_64", arch: "amd64", family: "unix"
2、下载插件包
github地址:https://github.com/medcl/elasticsearch-analysis-pinyin
下载zip包,并解压
wget https://codeload.github.com/medcl/elasticsearch-analysis-pinyin/zip/elasticsearch-analysis-pinyin-master.zip unzip elasticsearch-analysis-pinyin-master.zip
3、修改版本号
查看pom.xml文件中的版本号,需要修改和 es 的版本相同
cd elasticsearch-analysis-pinyin-master
vim pom.xml <elasticsearch.version>7.1.1</elasticsearch.version>
4、编译
mvn clean install -Dmaven.test.skip
在当前 target/releases 目录下生成了 elasticsearch-analysis-pinyin-7.1.1.zip 包
5、安装插件
安装插件很简单,只需要解压到 es 的 plugins 目录下即可
#新建目录
mkdir /opt/elasticsearch/plugins/analysis-pinyin
#复制插件包
cd target/releases
cp elasticsearch-analysis-pinyin-7.1.1.zip /opt/elasticsearch/plugins/analysis-pinyin
#解压
cd /opt/elasticsearch/plugins/analysis-pinyin unzip elasticsearch-analysis-pinyin-7.1.1.zip
6、重启es
../../bin/elasticsearch-plugin list service elasticsearch restart