Reputation: 617
I am aware of the @SortableField annotation and also of the MetadataProvidingFieldBridge.configureFieldMetadata method which provide ways to specify fields as being sortable in HS 5.
However these only apply at the time an index is created. In my app results can be tagged with arbitrary tags, which have an associated score, and I need to be able to sort on any of them. So the name of the field is the tag name and the value is the score of the tag.
Previously this worked with HS3 when any field could be used for sorting, but in v5 we have to tell HS about the sortable fields in advance.
So the question is: is it possible to add sortable fields dynamically when the user creates a new tag, and if so, how?
Upvotes: 0
Views: 523
Reputation: 9977
As explained here, your only solution is to set the configuration property hibernate.search.index_uninverting_allowed
to true
. It's not very efficient, and you will get warnings because of that, but then it wasn't very efficient in HS3 either (it worked the same).
Fields marked with @SortableField
will still get a performance boost and won't trigger a warning.
We do plan on adding a better, more efficient way to sort on dynamic fields in Hibernate Search 6.
Upvotes: 1