Brad Messerle
Brad Messerle

Reputation: 3

Spring Data Elastic Search 4.0.3 - List Of Dates Field

Lets say i have I have a list of birthdates

@Field(type = FieldType.Nested, includeInParent = true, format = DateFormat.date)
private List<LocalDate> birthdates = new ArrayList<>();

What is the proper way to map this using spring data without getting this error.. No converter found capable of converting from type [java.lang.Long] to type [java.time.LocalDate]

Do I really need to create a custom converter? or a wapper object? I would think this would be supported out of the box.

Thank you in advance.

Upvotes: 0

Views: 243

Answers (1)

Abacus
Abacus

Reputation: 19431

The correct way to annotate this property should be

@Field(type = FieldType.Date, format = DateFormat.date)
private List<LocalDate> birthdates = new ArrayList<>();

This would write the mappings entry as type date and format date, and storing and searching the array would work.

The bad news is that the current version of Spring Data Elasticsearch does not handle this correctly.

The good news is, that I just implemented the fix for this, it will be contained in versions 4.0.4.RELEASE and 4.1.0.RC1; both are planned to be released tomorrow.

Edit: both versions are released now

Upvotes: 0

Related Questions