ZonedDateTime cannot be indexed with Elasticsearch 2.4.1



Elasticsearch 2.4.1


Florian "><b>C</b>ourtial
November 16, 2016, 10:25 PM

One weird effect of using a Field on the getter like that

is that my elasticsearch document date is not updated when I update my model (using spring data), the date is correctly indexed only the first time:

I downgraded to elasticsearch 2.1 for now.

Btw as you may know elasticsearch fixed the issue 6 days ago in the 5.0.1 release, but hsearch is not yet compatible with the 5th version.

Yoann Rodière
November 17, 2016, 8:08 AM

Right... That's because Hibrnate Search, by default, will optimize reindexing, and will only reindex if a JPA property that is annotated with @Field is dirty.

To solve this, you could either:

  • annotate your new getter as @javax.persistence.Transient, as @Sanne wisely suggested: it will disable this state inspection optimizations altogether, and will make sure your entity is reindexed whenever a property that is not directly indexed (such as myDate) changed.

  • (maybe) add a dummy field with a custom, no-op field bridge directly on the myDate property, so that a change in myDate will trigger a reindexing. I haven't tested that, though: you may run into trouble.

And yes, Elasticsearch 5.0.1 got a fix but we'd rather need a 2.4.2, since Elasticsearch 5 introduces several major breaking changes, and we're not sure we'll be able to migrate in time for the 5.6.0.CR1 (see HSEARCH-2434)

Florian "><b>C</b>ourtial
November 17, 2016, 8:37 AM

My bad, I didn't know about @Transient, I should have tried. Thanks!

Sanne Grinovero
November 17, 2016, 1:21 PM

Hibernate Search will automatically skip indexing if the entities are not considered "dirty" on the indexed properties (so if you updated some properties of your entity, but didn't touch the ones which require an index update it will skip the index update).

When this doesn't work well - like when needing exotic workarounds like this - you can disable this optimisation using the = false configuration property. It is a global option though, so use it as last resort only.

Yoann Rodière
November 23, 2016, 9:09 AM

Elasticsearch 2.4.2 was just released with a fix:
Anyone can now avoid this issue by upgrading from 2.4.0/2.4.1 to the latest maintenance release.

Closing this issue as out of date following the Elasticsearch maintenance release.


Yoann Rodière


Yoann Rodière



Suitable for new contributors


Pull Request


Feedback Requested



Affects versions