Quarkus Opensearch Extension

The quarkus-opensearch extension allows you to connect to an OpenSearch cluster using the clients provided by the OpenSearch project.

OpenSearch Clients

OpenSearch provides three different flavours of clients for connecting to the cluster. This extension has support for all three of them.

OpenSearch REST (low-level) client

Core low-level client which lets you interact with OpenSearch clusters through HTTP methods and JSON, it is also used by the two other higher level clients for connecting to the cluster.

OpenSearch REST high-level client

The OpenSearch Java high-level REST client lets you interact with your OpenSearch clusters and indices through Java methods and data structures rather than HTTP methods and JSON.

OpenSearch Java client

Just like the OpenSearch REST high-level level, the OpenSearch Java client lets you interact with OpenSearch through Java methods and data structures. In comparison to the REST high-level, it has no dependency to org.opensearch:opensearch and also provides an async client implementation.

Installation

If you want to use this extension, you need to add the io.quarkiverse.opensearch:quarkus-opensearch-rest-client extension first to your build file.

For instance, with Maven, add the following dependency to your POM file:

<dependency>
    <groupId>io.quarkiverse.opensearch</groupId>
    <artifactId>quarkus-opensearch-rest-client</artifactId>
    <version>1.3.0</version>
</dependency>

OpenSearch REST high-level client

The REST high-level client depends on the REST client and does not require any additional configuration.

If you want to use this client all you need to do is add the io.quarkiverse.opensearch:quarkus-opensearch-rest-high-level-client extension first to your build file.

with Maven, add the following dependency to your POM file:

<dependency>
    <groupId>io.quarkiverse.opensearch</groupId>
    <artifactId>quarkus-opensearch-rest-high-level-client</artifactId>
    <version>1.3.0</version>
</dependency>

OpenSearch Java client

The java client depends on the REST client and does not require any additional configuration.

If you want to use this client all you need to do is add the io.quarkiverse.opensearch:quarkus-opensearch-java-client extension first to your build file.

with Maven, add the following dependency to your POM file:

<dependency>
    <groupId>io.quarkiverse.opensearch</groupId>
    <artifactId>quarkus-opensearch-java-client</artifactId>
    <version>1.3.0</version>
</dependency>

Extension Configuration Reference

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

Whether a health check is published in case the smallrye-health extension is present.

Environment variable: QUARKUS_OPENSEARCH_HEALTH_ENABLED

boolean

true

The list of hosts of the OpenSearch servers.

Environment variable: QUARKUS_OPENSEARCH_HOSTS

list of host:port

The protocol to use when contacting OpenSearch servers. Set to "https" to enable SSL/TLS.

Environment variable: QUARKUS_OPENSEARCH_PROTOCOL

string

http

The username for basic HTTP authentication.

Environment variable: QUARKUS_OPENSEARCH_USERNAME

string

The password for basic HTTP authentication.

Environment variable: QUARKUS_OPENSEARCH_PASSWORD

string

The connection timeout.

Environment variable: QUARKUS_OPENSEARCH_CONNECTION_TIMEOUT

Duration

15S

The socket timeout.

Environment variable: QUARKUS_OPENSEARCH_SOCKET_TIMEOUT

Duration

30S

The maximum number of connections to all the OpenSearch servers.

Environment variable: QUARKUS_OPENSEARCH_MAX_CONNECTIONS

int

20

The maximum number of connections per OpenSearch server.

Environment variable: QUARKUS_OPENSEARCH_MAX_CONNECTIONS_PER_ROUTE

int

10

The number of IO thread. By default, this is the number of locally detected processors.

Thread counts higher than the number of processors should not be necessary because the I/O threads rely on non-blocking operations, but you may want to use a thread count lower than the number of processors.

Environment variable: QUARKUS_OPENSEARCH_IO_THREAD_COUNTS

int

Defines if automatic discovery is enabled.

Environment variable: QUARKUS_OPENSEARCH_DISCOVERY_ENABLED

boolean

false

Refresh interval of the node list.

Environment variable: QUARKUS_OPENSEARCH_DISCOVERY_REFRESH_INTERVAL

Duration

5M

About the Duration format

To write duration values, use the standard java.time.Duration format. See the Duration#parse() javadoc for more information.

You can also use a simplified format, starting with a number:

  • If the value is only a number, it represents time in seconds.

  • If the value is a number followed by ms, it represents time in milliseconds.

In other cases, the simplified format is translated to the java.time.Duration format for parsing:

  • If the value is a number followed by h, m, or s, it is prefixed with PT.

  • If the value is a number followed by d, it is prefixed with P.