fix(search): respect DATE sort when text is present — do not override with relevance

When a user explicitly selects DATE sort with a text query active, the
previous code treated it identically to RELEVANCE, silently discarding
the user's sort choice. Remove DATE from the useRankOrder condition so
that explicit DATE sort always goes through the standard JPA sort path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-15 10:57:24 +02:00
parent 7ec3e6170d
commit 947d8aeb6c
2 changed files with 102 additions and 2 deletions

View File

@@ -319,8 +319,8 @@ public class DocumentService {
return sortBySender(results, dir);
}
// RELEVANCE: default when text present and no explicit non-relevance sort requested
boolean useRankOrder = hasText && (sort == null || sort == DocumentSort.RELEVANCE || sort == DocumentSort.DATE);
// RELEVANCE: default when text present and no explicit sort given
boolean useRankOrder = hasText && (sort == null || sort == DocumentSort.RELEVANCE);
if (useRankOrder) {
List<Document> results = documentRepository.findAll(spec);
final List<UUID> ids = rankedIds;