如何在laradock中安装ik分词器

IT知识
446
0
0
2022-05-11

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

ik分词器Github:github.com/medcl/elasticsearch-ana...

大家也可以关注我得blog: doc.orangbus.cn