Spring Data Elasticsearch Custom Converter

leocodms·2023년 3월 23일


목록 보기

LocalDatiTime Converter

class StringToLocalDateTimeConverter: Converter<String, LocalDateTime>{
    override fun convert(p: String): LocalDateTime =
        LocalDateTime.parse(p, LOCAL_DATE_TIME_FORMATTER)

class LocalDateTimeToStringConverter: Converter<LocalDateTime, String>{
    override fun convert(p: LocalDateTime): String =

Enum Converter Factory

To convert String to Enum type field, create enum class converter factory.

Backend Developer

1개의 댓글

2023년 12월 4일

Spring Data Elasticsearch Custom Converter allows seamless integration of Elasticsearch with various data formats. Developers can employ custom converters to handle specific data types during the indexing process. This capability enhances flexibility and efficiency in mapping data between Elasticsearch and the application. For example, when dealing with multimedia content, a custom converter could be utilized to transform URLs, such as https://converra.com/converter/avi/mp4 ensuring smooth integration of diverse content types into Elasticsearch indices. This versatility empowers developers to optimize data representation and retrieval in Elasticsearch, supporting a wide range of applications.

답글 달기