2

I have my entity class defined as follows:

@Document(indexName = "payload-pojo")
public class PayloadPojo {
    @Id
    private String id;

    @Field(index = false,type = FieldType.Binary)
    byte[] payload;

}

and the Repository defined as follows:

public interface PayloadRepository  extends ElasticsearchRepository<PayloadPojo, String>  {
}

In the ES 6.8.1 (Spring Data Elasticsearch 3.2.0) I managed to store and read the binary data without any problem.

Now I'd like to move to ES 7.5.2, so I migrated the project to use Spring Data Elasticsearch 4.0.0. Since then when I try to call something like payloadRepo.findAll() I get conversion exception: Failed to convert from type [java.lang.String] to type [byte]. The data is stored as base64 encoded string.

Do you have any idea of what has changed and how to change my code in order to read this value correctly?

Thanks

  • 3.2.0 did not yet have `FieldType.Binary`, I added this last August for the 4.0 branch. How was the mapping defined before that? Seems we need a converter for that. I will have a deeper look at this tomorrow. – P.J.Meisch Feb 13 '20 at 22:45
  • Thanks @P.J.Meisch The mapping was defined as Text before. By the way, I also had to create reading converters to convert from Long and from Integer to sql Timestamp which used to work for me before without any custom converter. – Gennady Lisiansky Feb 14 '20 at 19:54

1 Answers1

1

FieldType.Binary was added for the 4.0 release. What still was missing until now was a internal converter to convert between byte[] and base64 encoded strings (field type binary in elasticsearch is always base64 encoded).

I just added this, should be in the next snapshot release.

As for the date types: We have added support for the different Elasticsearch date formats and support custom date patterns as well - as Elasticsearch does. This support is available for the classes implementing the java.time.TemporalAccessor interface - basically the java.time.* classes.

We dropped the internal support of the old java.util.Date classes in favour of the java.time classes - java.sql.Timestamp is derived from java.util.Date.

We have breaking changes for the 4.0 release and this is one of them (reminds to update the docs).

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66