Skip to content

[Elasticsearch] Install ik plugin with docker image

Jinxin Chen edited this page Dec 11, 2019 · 1 revision

Use elasticsearch docker image

Here is the official docker image of elasticsearch :

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

You can follow this article to setup elasticsearch in your environment easily.

Install ik plugin

Here is an example to build your own image based on the official image:

FROM docker.elastic.co/elasticsearch/elasticsearch:5.3.0

RUN mkdir plugins/ik
RUN wget -P plugins/ik https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.3.0/elasticsearch-analysis-ik-5.3.0.zip
RUN unzip -d plugins/ik/ plugins/ik/elasticsearch-analysis-ik-5.3.0.zip

EXPOSE 9200 9300

The image will build with ik which's version is 5.3.0. You can get which version you should install from here : https://github.com/medcl/elasticsearch-analysis-ik.

Elasticsearch will auto install plugins in the plugins folder, so what you need to do is download plugins to the folder.

Config the default analyzer for index

  1. Create index.
PUT /blog
  1. Stop index created above.

You can't change the default analyzer to an opened index, so you must close it first.

POST /blog/_close
  1. Set analyzer
PUT /blog/_settings
{
	"index":{
		"analysis" : {
            "analyzer" : {
                "default" : {
                    "type" : "ik_smart"
                }
            }
        }
    }
}
  1. Open index
POST /blog/_open

Now you can check whether the default analyzer was changed successfully:

GET /blog/_settings

Clone this wiki locally