Index non-mapped field with @Transient

Description

Hello,

In previous version HS 5.X i was able to index non-mapped field but with the alpha 7 it's not working anymore :

Here the exemple :

Here the exception :

is there any way with the new version to do that ?

Environment

None

Activity

Show:
Yoann Rodière
July 8, 2019, 1:03 PM

Feel free to open questions on discourse or stackoverflow with the hibernate-search tag when you need information; it will be easier to find for other users with the same problem.

To answer your question, yes you can do that.

  • If this property is derived from actually persisted properties, you can tell Hibernate Search which ones, so that your entity will be properly reindexed on updates. Annotate the property like this:

  • If this property is really transient (i.e. it is not derived from persisted properties), or if you don't care about reindexing on updates, you can simply annotate it with @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.NO).

Guillaume Smet
July 8, 2019, 1:36 PM
Edited

maybe we could improve the error message then? If the property is transient, it won't be mapped for ORM so, for sure, it will be unknown. We should point the user to @IndexingDependency.

Yoann Rodière
July 9, 2019, 7:20 AM

Closing this ticket since I created HSEARCH-3634.
Thanks for the heads-up!

Flagged

Assignee

Unassigned

Reporter

Alexis CUCUMEL

Suitable for new contributors

Yes, likely

Pull Request

None

Feedback Requested

None

Affects versions

Priority

Major
Configure