| Hi, From what I heard, from Hibernate Search 5 on, adding a @SortableField annotation is required to perform any kind of sort on a field. This seems to apply to id fields too, since I get warnings in the logs if I don't. Unfortunately, putting an @SortableField on an @Id/@DocumentId will make Hibernate Search initialization explode when an entity (say Level2) is referenced from another (say Level1) as an @IndexedEmbedded: when parsing annotations for Level1, the engine will find the @SortableField on the id field of Level2, but will not find the id field on Level2 . And crash, with this kind of error :
Adding an @Field annotation on Entity2.id will not solve the issue, since it will crash another way (seems forbidden to add a field named exactly like the @Id field). Note that :
- this is tied to indexing entities: when there is no @Id annotation on the "id" attribute, I can freely define an @Field on the "id" attribute, and everything works fine.
- this will happen regardless of whether the id field is part of the @IndexedEmbedded or not.
I see two workarounds at the moment:
- refraining from adding the @SortField annotation (this works, after all)
- defining a separate @Field (named "idSort", for instance) just for sorting
Test case coming (I need the JIRA number) |