BlackLab
BlackLab copied to clipboard
Enable counting hits without storing all of them
If the user wants to know the total number of hits, but doesn't need all the hits, and is not sorting or grouping them, we might not need to instantiate and store all of the hits. This could save time and memory.
Of course, this is a trade-off; users often try several queries without sorting or grouping, but will eventually want to sort or group something, which will then take longer than if the original query had already stored all of the hits.
This could be implemented by providing an alternative to SearchCountFromResults
, e.g. SearchCountFromQuery
, that executes the query and iterates through the resulting Spans
without storing any hits.
We would want to instantiate this version of the count if we know that no sort or group (or other reason to fetch all hits) has been requested.