Using a SearchSort instance in multiple queries with the Lucene backend has side effects and leads to unexpected results

Description

It seems the creation of a SearchQuery mutates a SearchSort by calling org.hibernate.search.backend.lucene.types.sort.comparatorsource.impl.LuceneFieldComparatorSource#setOriginalParentQuery (the comparator source being a component of the SearchSort).

Thus, if we create two queries with the same SearchSort instance, the second SearchQuery will have the final word on what gets passed to setOriginalParentQuery, and then executing the first SearchQuery will lead to unexpected results (since the sort uses the wrong Lucene query internally).

SearchSort should be immutable in order to avoid that.

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Sprint

Priority

Created March 18, 2022 at 3:57 PM
Updated April 6, 2022 at 2:54 PM
Resolved March 21, 2022 at 8:14 AM