feat(search): upgrade to PostgreSQL full-text search with German stemming #237
@@ -323,12 +323,11 @@ public class DocumentService {
|
|||||||
boolean useRankOrder = hasText && (sort == null || sort == DocumentSort.RELEVANCE);
|
boolean useRankOrder = hasText && (sort == null || sort == DocumentSort.RELEVANCE);
|
||||||
if (useRankOrder) {
|
if (useRankOrder) {
|
||||||
List<Document> results = documentRepository.findAll(spec);
|
List<Document> results = documentRepository.findAll(spec);
|
||||||
final List<UUID> ids = rankedIds;
|
Map<UUID, Integer> rankMap = new HashMap<>();
|
||||||
|
for (int i = 0; i < rankedIds.size(); i++) rankMap.put(rankedIds.get(i), i);
|
||||||
return results.stream()
|
return results.stream()
|
||||||
.sorted(Comparator.comparingInt(doc -> {
|
.sorted(Comparator.comparingInt(
|
||||||
int idx = ids.indexOf(doc.getId());
|
doc -> rankMap.getOrDefault(doc.getId(), Integer.MAX_VALUE)))
|
||||||
return idx < 0 ? Integer.MAX_VALUE : idx;
|
|
||||||
}))
|
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user