Class ElasticsearchConfigurationSupport

java.lang.Object
org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport
Direct Known Subclasses:
ElasticsearchConfiguration, ElasticsearchLegacyRestClientConfiguration, ReactiveElasticsearchConfiguration, ReactiveElasticsearchLegacyRestClientConfiguration

@Configuration(proxyBeanMethods=false) public class ElasticsearchConfigurationSupport extends Object
Since:
3.2
Author:
Christoph Strobl, Peter-Josef Meisch
  • Constructor Details

    • ElasticsearchConfigurationSupport

      public ElasticsearchConfigurationSupport()
  • Method Details

    • elasticsearchEntityMapper

      @Bean public ElasticsearchConverter elasticsearchEntityMapper(SimpleElasticsearchMappingContext elasticsearchMappingContext, ElasticsearchCustomConversions elasticsearchCustomConversions)
    • elasticsearchMappingContext

      @Bean public SimpleElasticsearchMappingContext elasticsearchMappingContext(ElasticsearchCustomConversions elasticsearchCustomConversions)
      Creates a SimpleElasticsearchMappingContext equipped with entity classes scanned from the mapping base package.
      Returns:
      never null.
      See Also:
    • elasticsearchCustomConversions

      @Bean public ElasticsearchCustomConversions elasticsearchCustomConversions()
      Register custom Converters in a ElasticsearchCustomConversions object if required.
      Returns:
      never null.
    • getMappingBasePackages

      protected Collection<String> 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 a com.acme.AppConfig extending ElasticsearchConfigurationSupport the base package will be considered com.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

      protected Set<Class<?>> getInitialEntitySet()
      Scans the mapping base package for classes annotated with Document. By default, it scans for entities in all packages returned by getMappingBasePackages().
      Returns:
      never null.
      See Also:
    • scanForEntities

      protected Set<Class<?>> scanForEntities(String basePackage)
      Scans the given base package for entities, i.e. Elasticsearch specific types annotated with Document.
      Parameters:
      basePackage - must not be null.
      Returns:
      never null.
    • refreshPolicy

      protected @Nullable RefreshPolicy refreshPolicy()
      Set up the write RefreshPolicy. Default is set to null to use the cluster defaults..
      Returns:
      null to use the server defaults.
    • fieldNamingStrategy

      protected FieldNamingStrategy fieldNamingStrategy()
      Configures a FieldNamingStrategy on the SimpleElasticsearchMappingContext 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