Class ElasticsearchConfigurationSupport
java.lang.Object
org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport
- Direct Known Subclasses:
ElasticsearchConfiguration
,ReactiveElasticsearchConfiguration
@Configuration(proxyBeanMethods=false)
public class ElasticsearchConfigurationSupport
extends Object
- Since:
- 3.2
- Author:
- Christoph Strobl, Peter-Josef Meisch
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRegister customConverter
s in aElasticsearchCustomConversions
object if required.elasticsearchEntityMapper
(SimpleElasticsearchMappingContext elasticsearchMappingContext, ElasticsearchCustomConversions elasticsearchCustomConversions) elasticsearchMappingContext
(ElasticsearchCustomConversions elasticsearchCustomConversions) Creates aSimpleElasticsearchMappingContext
equipped with entity classes scanned from the mapping base package.protected FieldNamingStrategy
Configures aFieldNamingStrategy
on theSimpleElasticsearchMappingContext
instance created.Scans the mapping base package for classes annotated withDocument
.protected Collection<String>
Returns the base packages to scan for Elasticsearch mapped entities at startup.protected RefreshPolicy
Set up the writeRefreshPolicy
.scanForEntities
(String basePackage) Scans the given base package for entities, i.e.protected boolean
Flag specifiying if type hints (_class fields) should be written in the index.
-
Constructor Details
-
ElasticsearchConfigurationSupport
public ElasticsearchConfigurationSupport()
-
-
Method Details
-
elasticsearchEntityMapper
@Bean public ElasticsearchConverter elasticsearchEntityMapper(SimpleElasticsearchMappingContext elasticsearchMappingContext, ElasticsearchCustomConversions elasticsearchCustomConversions) -
elasticsearchMappingContext
@Bean public SimpleElasticsearchMappingContext elasticsearchMappingContext(ElasticsearchCustomConversions elasticsearchCustomConversions) Creates aSimpleElasticsearchMappingContext
equipped with entity classes scanned from the mapping base package.- Returns:
- never null.
- See Also:
-
elasticsearchCustomConversions
Register customConverter
s in aElasticsearchCustomConversions
object if required.- Returns:
- never null.
-
getMappingBasePackages
Returns the base packages to scan for Elasticsearch mapped entities at startup. Will return the package name of the configuration class' (the concrete class, not this one here) by default. So if you have acom.acme.AppConfig
extendingElasticsearchConfigurationSupport
the base package will be consideredcom.acme
unless the method is overridden to implement alternate behavior.- Returns:
- the base packages to scan for mapped
Document
classes or an empty collection to not enable scanning for entities.
-
getInitialEntitySet
Scans the mapping base package for classes annotated withDocument
. By default, it scans for entities in all packages returned bygetMappingBasePackages()
.- Returns:
- never null.
- See Also:
-
scanForEntities
Scans the given base package for entities, i.e. Elasticsearch specific types annotated withDocument
.- Parameters:
basePackage
- must not be null.- Returns:
- never null.
-
refreshPolicy
Set up the writeRefreshPolicy
. Default is set to null to use the cluster defaults..- Returns:
- null to use the server defaults.
-
fieldNamingStrategy
Configures aFieldNamingStrategy
on theSimpleElasticsearchMappingContext
instance created.- Returns:
- the
FieldNamingStrategy
to use - Since:
- 4.2
-
writeTypeHints
protected boolean writeTypeHints()Flag specifiying if type hints (_class fields) should be written in the index. It is strongly advised to keep the default value of true. If you need to write to an existing index that does not have a mapping defined for these fields and that has a strict mapping set, then it might be necessary to disable type hints. But notice that in this case reading polymorphic types may fail.- Returns:
- flag if type hints should be written
- Since:
- 4.3
-