Class ElasticsearchConfiguration
java.lang.Object
org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport
org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration
Base class for a @
Configuration
class to set up the Elasticsearch
connection using the Elasticsearch Client. This class exposes different parts of the setup as Spring beans. Deriving
classes must provide the ClientConfiguration
to use.- Since:
- 4.4
- Author:
- Peter-Josef Meisch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ClientConfiguration
Must be implemented by deriving classes to provide theClientConfiguration
.co.elastic.clients.elasticsearch.ElasticsearchClient
elasticsearchClient
(co.elastic.clients.transport.ElasticsearchTransport transport) Provides theElasticsearchClient
to be used.elasticsearchOperations
(ElasticsearchConverter elasticsearchConverter, co.elastic.clients.elasticsearch.ElasticsearchClient elasticsearchClient) Creates aElasticsearchOperations
implementation using anElasticsearchClient
.org.elasticsearch.client.RestClient
elasticsearchRestClient
(ClientConfiguration clientConfiguration) Provides the underlying low level Elasticsearch RestClient.co.elastic.clients.transport.ElasticsearchTransport
elasticsearchTransport
(org.elasticsearch.client.RestClient restClient, co.elastic.clients.json.JsonpMapper jsonpMapper) Provides the Elasticsearch transport to be used.co.elastic.clients.json.JsonpMapper
Provides the JsonpMapper bean that is used in theelasticsearchTransport(RestClient, JsonpMapper)
method.co.elastic.clients.transport.TransportOptions
Methods inherited from class org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport
elasticsearchCustomConversions, elasticsearchEntityMapper, elasticsearchMappingContext, fieldNamingStrategy, getInitialEntitySet, getMappingBasePackages, refreshPolicy, scanForEntities, writeTypeHints
-
Constructor Details
-
ElasticsearchConfiguration
public ElasticsearchConfiguration()
-
-
Method Details
-
clientConfiguration
@Bean(name="elasticsearchClientConfiguration") public abstract ClientConfiguration clientConfiguration()Must be implemented by deriving classes to provide theClientConfiguration
.- Returns:
- configuration, must not be null
-
elasticsearchRestClient
@Bean public org.elasticsearch.client.RestClient elasticsearchRestClient(ClientConfiguration clientConfiguration) Provides the underlying low level Elasticsearch RestClient.- Parameters:
clientConfiguration
- configuration for the client, must not be null- Returns:
- RestClient
-
elasticsearchTransport
@Bean public co.elastic.clients.transport.ElasticsearchTransport elasticsearchTransport(org.elasticsearch.client.RestClient restClient, co.elastic.clients.json.JsonpMapper jsonpMapper) Provides the Elasticsearch transport to be used. The default implementation uses theRestClient
bean and theJsonpMapper
bean provided in this class.- Returns:
- the
ElasticsearchTransport
- Since:
- 5.2
-
elasticsearchClient
@Bean public co.elastic.clients.elasticsearch.ElasticsearchClient elasticsearchClient(co.elastic.clients.transport.ElasticsearchTransport transport) Provides theElasticsearchClient
to be used.- Parameters:
transport
- theElasticsearchTransport
to use- Returns:
- ElasticsearchClient instance
-
elasticsearchOperations
@Bean(name={"elasticsearchOperations","elasticsearchTemplate"}) public ElasticsearchOperations elasticsearchOperations(ElasticsearchConverter elasticsearchConverter, co.elastic.clients.elasticsearch.ElasticsearchClient elasticsearchClient) Creates aElasticsearchOperations
implementation using anElasticsearchClient
.- Returns:
- never null.
-
jsonpMapper
Provides the JsonpMapper bean that is used in theelasticsearchTransport(RestClient, JsonpMapper)
method.- Returns:
- the
JsonpMapper
to use - Since:
- 5.2
-
transportOptions
public co.elastic.clients.transport.TransportOptions transportOptions()- Returns:
- the options that should be added to every request. Must not be null
-