This is a docker compose file for running elastic search in a docker container. It is based on the official elastic search docker image. It is configured to run elastic on port 9200 and kibana on port 5601.
Create .env file with the following content:
ELASTIC_VERSION=8.5.0
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=123456
Where ELASTIC_VERSION is the version of elastic search you want to run(checkout this link for available versions). ELASTIC_SECURITY is a boolean value that determines if you want to enable security on elastic search. ELASTIC_PASSWORD is the password for the elastic user.
Then run the following command:
docker-compose up -dFor logs:
docker-compose logs -fStop elastic search:
docker-compose downWe also provide a example usecase for indexing and searching. The scripts are located in example directory. To run the example, first create a virtual conda environment and install the dependencies by running:
conda env create -f environment.yml
conda activate elasticTo index data, you can use the elastic search bulk api. For example, checkout the example here. To query data, you can use the elastic search search api. In the example, we use the elasticsearch-dsl library to query data. Checkout the example here.
You can monitor the elastic search cluster using the kibana dashboard. To access the kibana dashboard, go to http://localhost:5601 in your browser. You will be prompted to enter the elastic user password. The default password is changeme. You can change the password by setting the ELASTIC_PASSWORD environment variable in the .env file.