Skip to content

Commit

Permalink
HSEARCH-3125 Document the API allowing to retrieve the Elasticsearch …
Browse files Browse the repository at this point in the history
…client
  • Loading branch information
yrodiere committed Apr 26, 2018
1 parent ee0e58c commit 131a7fe
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions documentation/src/main/asciidoc/elasticsearch-integration.asciidoc
Expand Up @@ -1116,6 +1116,32 @@ The optimization features documented in <<search-optimize>> are only partially i
* The automatic optimization is not implemented and most probably never will be.
* The manual optimization (`searchFactory.optimize()`) is implemented.

[[elasticsearch-client-access]]
=== Direct access to the Elasticsearch client

When writing complex applications with advanced requirements,
it may be necessary from time to time to send requests to the Elasticsearch cluster directly,
in particular if Hibernate Search does not support this kind of requests out of the box.

To that end, you can access the Elasticsearch client
used by Hibernate Search internally with the following snippet of code:

[source,java]
--
SearchFactory searchFactory = fullTextSession.getSearchFactory();
IndexFamily indexFamily = searchFactory.getIndexFamily( ElasticsearchIndexFamilyType.get() );
ElasticsearchIndexFamily elasticsearchIndexFamily = indexFamily.unwrap( ElasticsearchIndexFamily.class );
RestClient restClient = elasticsearchIndexFamily.getClient( RestClient.class );
--

[WARNING]
====
The client itself is not part of the Hibernate Search API, but of the official Elasticsearch REST client API.
If we have to switch the internal implementation to another client with a different Java type,
which we may do without prior notice, the snippet of code above will throw an exception.
====

[[elasticsearch-logging]]
==== Logging executed requests

Expand Down

0 comments on commit 131a7fe

Please sign in to comment.