apache / apache/lucene

TotalHitCountCollector to stop counting when threshold is reached

Open
#12,230 4 comments 0 reactions 1 assignee Claimed by @javanna View on GitHub
type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

`TopScoreDocCollector` stops collecting hits as well as counting total hits when the provided total hits threshold is reached. Would it make sense to introduce a similar mechanism to `TotalHitCountCollector` so that you can provide a `numHitsThreshold` at initialization time and it will stop counting total hits as soon as the threshold is reached? This is consistent to the behaviour when collecting hits, in case users are not interested in accurate hit counts, and can make collection faster in that case: why keep counting if we have already counted enough hits?

This is something that Elasticsearch supports today by wrapping the total hit count collector with a collector that does early termination. I thought it's simple enough and convenient to have such a mechanism built-in in Lucene, and without requiring to wrap the collector.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.