Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 2.28 KB

File metadata and controls

50 lines (36 loc) · 2.28 KB

Elasticsearch container

This module helps running elasticsearch using Testcontainers.

Note that it's based on the official Docker image provided by elastic.

Usage example

You can start an elasticsearch container instance from any Java application by using:

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

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.

Secure your Elasticsearch cluster

The default distribution of Elasticsearch comes with the basic license which contains security feature. You can turn on security by providing a password:

HttpClient inside_block:httpClientSecuredContainer

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

=== "Gradle" groovy testImplementation "org.testcontainers:elasticsearch:{{latest_version}}"

=== "Maven" xml <dependency> <groupId>org.testcontainers</groupId> <artifactId>elasticsearch</artifactId> <version>{{latest_version}}</version> <scope>test</scope> </dependency>