Using search instead of count is too heavy

This commit is contained in:
Andrea Cavalli 2021-12-18 00:18:24 +01:00
parent 0f62362d21
commit 9952eaffc0

View File

@ -126,13 +126,7 @@ public class CountMultiSearcher implements MultiSearcher {
try (var is = indexSearcher.receive()) {
LLUtils.ensureBlocking();
// If the timeout is very big, use the default count without timeout, because it's faster
if (queryParams2.timeout().compareTo(Duration.ofHours(1)) >= 0) {
return (long) is.getIndexSearcher().count(queryParams2.query());
} else {
var totalHitsCountCollectorManager = new TotalHitCountCollectorManager(queryParams2.timeout());
return is.getIndexSearcher().search(queryParams2.query(), totalHitsCountCollectorManager);
}
}
}).subscribeOn(uninterruptibleScheduler(Schedulers.boundedElastic())))
.publishOn(Schedulers.parallel())