@@ -163,7 +163,25 @@ which needs to be enabled explicitly.
163163== Client configuration
164164
165165An Elasticsearch backend communicates with an Elasticsearch cluster through a REST client.
166- Below are the options that affect this client.
166+ Hibernate Search comes with a range of pluggable Elasticsearch REST clients that the user can pick from:
167+
168+ [[backend-elasticsearch-configuration-client-elasticsearch-client-rest]]
169+ `hibernate-search-backend-elasticsearch-client-rest`::
170+ Description::: The Elasticsearch low level client based implementation (`org.elasticsearch.client:elasticsearch-rest-client`).
171+ Currently, the default REST client used by the Elasticsearch backend.
172+ Underlying HTTP Client::: Apache HTTP Client 4
173+
174+ [[backend-elasticsearch-configuration-client-elasticsearch-client-java]]
175+ `hibernate-search-backend-elasticsearch-client-java`::
176+ Description::: The Elasticsearch Java client based implementation (`co.elastic.clients:elasticsearch-java`).
177+ Underlying HTTP Client::: Apache HTTP Client 5
178+
179+ [[backend-elasticsearch-configuration-client-elasticsearch-client-opensearch]]
180+ `hibernate-search-backend-elasticsearch-client-opensearch`::
181+ Description::: The OpenSearch low level client based implementation (`org.opensearch.client:opensearch-rest-client`).
182+ Underlying HTTP Client::: Apache HTTP Client 5
183+
184+ Below are the options that affect these clients.
167185
168186[[backend-elasticsearch-configuration-hosts]]
169187=== Target hosts
@@ -212,6 +230,8 @@ There are some constraints regarding the use of this property:
212230* The provided list of URIs must not be empty.
213231====
214232
233+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
234+
215235[[backend-elasticsearch-configuration-path-prefix]]
216236=== Path prefix
217237
@@ -231,6 +251,8 @@ hibernate.search.backend.path_prefix = my/path
231251With the above, a search query targeting all indexes will be sent to path `/my/path/_search` instead of `/_search`.
232252The path will be prefixed similarly for all requests sent to Elasticsearch.
233253
254+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
255+
234256[[backend-elasticsearch-configuration-discovery]]
235257=== Node discovery
236258
@@ -250,6 +272,8 @@ Expects a boolean value. The default for this property is `false`.
250272* `discovery.refresh_interval` defines the interval between two executions of the automatic discovery.
251273Expects a positive integer, in seconds. The default for this property is `10`.
252274
275+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
276+
253277[[backend-elasticsearch-authentication-http]]
254278=== HTTP authentication
255279
@@ -271,6 +295,8 @@ If you use HTTP instead of HTTPS (see above),
271295your password will be transmitted in clear text over the network.
272296====
273297
298+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
299+
274300[[backend-elasticsearch-configuration-aws]]
275301=== [[elasticsearch-integration-configuration-aws]] Authentication on Amazon Web Services
276302
@@ -339,6 +365,8 @@ http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html[secre
339365Expects a string value.
340366This property has no default and must be provided when the credentials type is set to `static`.
341367
368+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
369+
342370[[backend-elasticsearch-configuration-connection-tuning]]
343371=== [[_connection_tuning]] Connection tuning
344372
@@ -362,6 +390,9 @@ The default for this property is `30000`.
362390+
363391These properties expect a positive <<configuration-property-types,Integer value>> in milliseconds, such as `3000`.
364392
393+ +
394+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
395+
365396Connection pool::
366397+
367398[source, properties]
@@ -396,6 +427,9 @@ as those would be struggling to get a connection.
396427To prevent that from happening consider having the maximum number of connections greater than the number of active indexing queues.
397428====
398429
430+ +
431+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
432+
399433Keep Alive::
400434+
401435[source, properties]
@@ -412,29 +446,39 @@ the duration from the `Keep-Alive` header or the value of this property (if set)
412446+
413447If this property is not set, only the `Keep-Alive` header is considered,
414448and if it's absent, idle connections will be kept forever.
449+ +
450+ include::../components/elasticsearch-client-compatibility/_all.adoc[]
415451
416452[[backend-elasticsearch-configuration-http-client]]
417453=== [[_custom_http_client_configurations]] Custom HTTP client configurations
418454
419- It is possible to configure the HTTP client directly
455+ Each of the pluggable REST clients allow for additional configuration of the underlying
456+ HTTP client through configurers.
457+
458+ See the following sections to learn how each of the clients can be configured.
459+
460+ [[backend-elasticsearch-configuration-http-client-elasticsearch-rest]]
461+ === Elasticsearch low level client
462+ It is possible to directly configure the underlying Apache HTTP 4 client of the
463+ <<backend-elasticsearch-configuration-client-elasticsearch-client-rest,Elasticsearch low level client>>
420464using an instance of `org.apache.http.impl.nio.client.HttpAsyncClientBuilder`.
421465
422466With this API you can add interceptors, change the keep alive, the max connections,
423467the SSL key/trust store settings and many other client configurations.
424468
425- Configure the HTTP client directly requires two steps:
469+ Configuring the HTTP client directly requires two steps:
426470
427- . Define a class that implements the `org.hibernate.search.backend.elasticsearch.client.ElasticsearchHttpClientConfigurer` interface.
471+ . Define a class that implements the `org.hibernate.search.backend.elasticsearch.client.rest. ElasticsearchHttpClientConfigurer` interface.
428472. Configure Hibernate Search to use that implementation by setting the configuration property
429473`hibernate.search.backend.client.configurer`
430474to a <<configuration-bean-reference-parsing,bean reference>> pointing to the implementation,
431- for example `class:org.hibernate.search.documentation.backend.elasticsearch.client.HttpClientConfigurer`.
475+ for example `class:org.hibernate.search.documentation.backend.elasticsearch.client.rest. HttpClientConfigurer`.
432476
433477.Implementing and using a `ElasticsearchHttpClientConfigurer`
434478====
435479[source, java, indent=0, subs="+callouts"]
436480----
437- include::{sourcedir}/org/hibernate/search/documentation/backend/elasticsearch/client/HttpClientConfigurer.java[tags=include]
481+ include::{sourcedir}/org/hibernate/search/documentation/backend/elasticsearch/client/rest/ HttpClientConfigurer.java[tags=include]
438482----
439483<1> The class has to implement the `ElasticsearchHttpClientConfigurer` interface.
440484<2> The `configure` method provides the access to the `ElasticsearchHttpClientConfigurationContext`.
@@ -456,6 +500,92 @@ include::{resourcesdir}/configuration/http-client-configurer.properties[tags=inc
456500Any setting defined by a custom http client configurer will override any other setting defined by Hibernate Search.
457501====
458502
503+ [[backend-elasticsearch-configuration-http-client-elasticsearch-java]]
504+ === Elasticsearch java client
505+ It is possible to directly configure the underlying Apache HTTP 5 client of the
506+ <<backend-elasticsearch-configuration-client-elasticsearch-client-java,Elasticsearch java client>>
507+ using an instance of `org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder`.
508+
509+ With this API you can add interceptors, change the keep alive, the max connections,
510+ the SSL key/trust store settings and many other client configurations.
511+
512+ Configuring the HTTP client directly requires two steps:
513+
514+ . Define a class that implements the `org.hibernate.search.backend.elasticsearch.client.java.ElasticsearchHttpClientConfigurer` interface.
515+ . Configure Hibernate Search to use that implementation by setting the configuration property
516+ `hibernate.search.backend.client.configurer`
517+ to a <<configuration-bean-reference-parsing,bean reference>> pointing to the implementation,
518+ for example `class:org.hibernate.search.documentation.backend.elasticsearch.client.java.HttpClientConfigurer`.
519+
520+ .Implementing and using a `ElasticsearchHttpClientConfigurer`
521+ ====
522+ [source, java, indent=0, subs="+callouts"]
523+ ----
524+ include::{sourcedir}/org/hibernate/search/documentation/backend/elasticsearch/client/java/HttpClientConfigurer.java[tags=include]
525+ ----
526+ <1> The class has to implement the `ElasticsearchHttpClientConfigurer` interface.
527+ <2> The `configure` method provides the access to the `ElasticsearchHttpClientConfigurationContext`.
528+ <3> From the context it is possible to get the `HttpAsyncClientBuilder`.
529+ <4> Finally, you can use the builder to configure the client with your custom settings.
530+ ====
531+
532+ .Define a custom http client configurer in the properties
533+ ====
534+ [source, xml, indent=0, subs="+callouts"]
535+ ----
536+ include::{resourcesdir}/configuration/http-client-configurer-java.properties[tags=include]
537+ ----
538+ <1> Specify the HTTP client configurer.
539+ ====
540+
541+ [NOTE]
542+ ====
543+ Any setting defined by a custom http client configurer will override any other setting defined by Hibernate Search.
544+ ====
545+
546+ [[backend-elasticsearch-configuration-http-client-elasticsearch-opensearch]]
547+ === OpenSearch low level client
548+ It is possible to directly configure the underlying Apache HTTP 5 client of the
549+ <<backend-elasticsearch-configuration-client-elasticsearch-client-java,OpenSearch low level client>>
550+ using an instance of `org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder`.
551+
552+ With this API you can add interceptors, change the keep alive, the max connections,
553+ the SSL key/trust store settings and many other client configurations.
554+
555+ Configuring the HTTP client directly requires two steps:
556+
557+ . Define a class that implements the `org.hibernate.search.backend.elasticsearch.client.opensearch.ElasticsearchHttpClientConfigurer` interface.
558+ . Configure Hibernate Search to use that implementation by setting the configuration property
559+ `hibernate.search.backend.client.configurer`
560+ to a <<configuration-bean-reference-parsing,bean reference>> pointing to the implementation,
561+ for example `class:org.hibernate.search.documentation.backend.elasticsearch.client.opensearch.HttpClientConfigurer`.
562+
563+ .Implementing and using a `ElasticsearchHttpClientConfigurer`
564+ ====
565+ [source, java, indent=0, subs="+callouts"]
566+ ----
567+ include::{sourcedir}/org/hibernate/search/documentation/backend/elasticsearch/client/java/HttpClientConfigurer.java[tags=include]
568+ ----
569+ <1> The class has to implement the `ElasticsearchHttpClientConfigurer` interface.
570+ <2> The `configure` method provides the access to the `ElasticsearchHttpClientConfigurationContext`.
571+ <3> From the context it is possible to get the `HttpAsyncClientBuilder`.
572+ <4> Finally, you can use the builder to configure the client with your custom settings.
573+ ====
574+
575+ .Define a custom http client configurer in the properties
576+ ====
577+ [source, xml, indent=0, subs="+callouts"]
578+ ----
579+ include::{resourcesdir}/configuration/http-client-configurer-opensearch.properties[tags=include]
580+ ----
581+ <1> Specify the HTTP client configurer.
582+ ====
583+
584+ [NOTE]
585+ ====
586+ Any setting defined by a custom http client configurer will override any other setting defined by Hibernate Search.
587+ ====
588+
459589[[backend-elasticsearch-configuration-version]]
460590== [[backend-elasticsearch-configuration-dialect]] Version compatibility
461591
0 commit comments