简体   繁体   English

Spring Data Elastic Search 4.0.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]使用 spring 数据映射它而不会出现此错误的正确方法是什么.. 找不到能够从 [java.lang.Long] 类型转换为 [java.time.LocalDate] 类型的转换器

Do I really need to create a custom converter?我真的需要创建自定义转换器吗? or a wapper object?还是一个wapper对象? I would think this would be supported out of the box.我认为这将得到开箱即用的支持。

Thank you in advance.先感谢您。

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.这会将映射条目写为类型date和格式date ,并且存储和搜索数组将起作用。

The bad news is that the current version of Spring Data Elasticsearch does not handle this correctly.坏消息是当前版本的 Spring Data Elasticsearch 没有正确处理这个问题。

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;好消息是,我刚刚为此实施了修复程序,它将包含在版本 4.0.4.RELEASE 和 4.1.0.RC1 中; both are planned to be released tomorrow.两者都计划于明天发布。

Edit: both versions are released now编辑:两个版本现已发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM