Class MappingElasticsearchConverter
java.lang.Object
org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter
- All Implemented Interfaces:
Aware,InitializingBean,ApplicationContextAware,EnvironmentCapable,EntityConverter<ElasticsearchPersistentEntity<?>,,ElasticsearchPersistentProperty, Object, Document> EntityReader<Object,,Document> EntityWriter<Object,,Document> ElasticsearchConverter
public class MappingElasticsearchConverter
extends Object
implements ElasticsearchConverter, ApplicationContextAware, InitializingBean, EnvironmentCapable
Elasticsearch specific
EntityConverter implementation based on domain type
metadata.- Since:
- 3.2
- Author:
- Rizwan Idrees, Mohsin Husen, Christoph Strobl, Peter-Josef Meisch, Mark Paluch, Roman Puchkovskiy, Konrad Kurdej, Subhobrata Dey, Marc Vanbrabant, Anton Naydenov, vdisk, Junghoon Ban, llosimura
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext, GenericConversionService conversionService) -
Method Summary
Modifier and TypeMethodDescriptionvoid<R> RvoidsetApplicationContext(ApplicationContext applicationContext) voidsetConversions(CustomConversions conversions) Set theCustomConversionsto be applied during the mapping process.updateFieldNames(String propertyPath, ElasticsearchPersistentEntity<?> persistentEntity) Replaces the parts in a dot separated property path with the field names of the respective properties.voidupdateQuery(Query query, Class<?> domainClass) Updates aQueryby renaming the property names in the query to the correct mapped field names and the values to the converted values if theElasticsearchPersistentPropertyfor a property has aPropertyValueConverter.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter
convertId, getProjectionFactory, mapObject
-
Field Details
-
environment
-
-
Constructor Details
-
MappingElasticsearchConverter
public MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) -
MappingElasticsearchConverter
public MappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext, @Nullable GenericConversionService conversionService)
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
getEnvironment
- Specified by:
getEnvironmentin interfaceEnvironmentCapable
-
getMappingContext
public MappingContext<? extends ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty> getMappingContext()- Specified by:
getMappingContextin interfaceEntityConverter<ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty, Object, Document>
-
getConversionService
- Specified by:
getConversionServicein interfaceEntityConverter<ElasticsearchPersistentEntity<?>,ElasticsearchPersistentProperty, Object, Document>
-
setConversions
Set theCustomConversionsto be applied during the mapping process.
Conversions are registered afterbean initialization.- Parameters:
conversions- must not be null.
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
getTypeMapper
-
read
- Specified by:
readin interfaceEntityReader<Object,Document>
-
write
- Specified by:
writein interfaceEntityWriter<Object,Document>
-
updateQuery
Description copied from interface:ElasticsearchConverterUpdates aQueryby renaming the property names in the query to the correct mapped field names and the values to the converted values if theElasticsearchPersistentPropertyfor a property has aPropertyValueConverter. If domainClass is null it's a noop.- Specified by:
updateQueryin interfaceElasticsearchConverter- Parameters:
query- the query that is internally updated, must not be nulldomainClass- the class of the object that is searched with the query
-
updateFieldNames
public String updateFieldNames(String propertyPath, ElasticsearchPersistentEntity<?> persistentEntity) Description copied from interface:ElasticsearchConverterReplaces the parts in a dot separated property path with the field names of the respective properties. If no matching property is found, the original parts are rteturned.- Specified by:
updateFieldNamesin interfaceElasticsearchConverter- Parameters:
propertyPath- the property pathpersistentEntity- the replaced values.- Returns:
- a String wihere the property names are replaced with field names
-