DateBridge for ZonedDateTime in hibernate search gives exception while indexing the data DateBridge for ZonedDateTime in hibernate search gives exception while indexing the data elasticsearch elasticsearch

DateBridge for ZonedDateTime in hibernate search gives exception while indexing the data


A ZoneOffset is a ZoneId, so this code is correct:

    ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC);

However, Hibernate Search uses a very specific format when serializing zoned date times to JSON. That format requires that an actual region ID be present (not just an offset).

That can be considered as a bug, and you're welcome to open a bug report, but I'm afraid that's not the only problem. Even if this problem was fixed in Search 5, in order to successfully index such a value, we would still need to backport a fix for HSEARCH-3548, which as far as I understand requires backward-incompatible changes to the Elasticsearch mapping generated by Hibernate Search. So I'm not sure this is something that can actually be fixed in 5.11.

Elasticsearch support in Hibernate Search 5 is experimental. If you can, you'll have a much better time upgrading to Hibernate Search 6 (still in beta) which provides first-class support for Elasticsearch 5.6 to 7.x, and which actually has a test for your specific problem (and it works correctly). The APIs in Hibernate Search 6 are different, however.