1、进入 laradock/elasticsearch 修改 Dockerfile
ARG ELK_VERSION
FROM elasticsearch:${ELK_VERSION}
# 添加下面一行安装命令
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.1/elasticsearch-analysis-ik-7.9.1.zip
EXPOSE 9200 9300
注意:ik 分词器的版本要和 elasticsearch 的版本是一致的,不然会报错.
可以先通过 docker images | grep elassticsearch 查看一下 search 的版本
考虑到在我天朝下载 github 的东西会比较慢,可以先下载 ik 再 copy 进去
mkdir -p pathto/laradock/elasticsearch/plugins
|-- Dockerfile
`-- plugins
`-- elasticsearch-analysis-ik-7.9.1.zip
修改 elasticsearch/Dockerfile
COPY ./plugins/elasticsearch-analysis-ik-7.9.1.zip /usr/share/elasticsearch/plugins
2、重新 build
docker-compose build elasticsearch
3、最后,查看是否安装成功:
docker-compose exec elasticsearch /usr/share/elasticsearch/bin/elasticsearch-plugin list
分词器:https://github.com/medcl/elasticsearch-analysis-ik/tree/v7.9.1