docs/modules/elasticsearch.md
This module helps running elasticsearch using Testcontainers.
Note that it's based on the official Docker image provided by elastic.
You can start an elasticsearch container instance from any Java application by using:
<!--codeinclude-->HttpClient inside_block:httpClientContainer7 HttpClient with Elasticsearch 8 inside_block:httpClientContainer8 HttpClient with Elasticsearch 8 and SSL disabled inside_block:httpClientContainerNoSSL8 TransportClient inside_block:transportClientContainer
<!--/codeinclude-->Note that if you are still using the TransportClient
(not recommended as it is deprecated), the default cluster name is set to docker-cluster so you need to change cluster.name setting
or set client.transport.ignore_cluster_name to true.
The default distribution of Elasticsearch comes with the basic license which contains security feature. You can turn on security by providing a password:
<!--codeinclude-->HttpClient inside_block:httpClientSecuredContainer
<!--/codeinclude-->Add the following dependency to your pom.xml/build.gradle file:
=== "Gradle"
groovy testImplementation "org.testcontainers:testcontainers-elasticsearch:{{latest_version}}"
=== "Maven"
xml <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers-elasticsearch</artifactId> <version>{{latest_version}}</version> <scope>test</scope> </dependency>