Is there any way to get the total hit count from Lucene’s TopDocs.totalHits? It would be wonderful if that information was available somewhere in the query result, maybe through the
$meta operator, because using
$count in the aggregation pipeline is extremely slow depending on the size of the result set. E.g. our collection has 2 million documents, and
$count takes an average of 8 seconds on a result set of ~12k hits. The pipeline has only two steps:
$search followed by
$count. The search step is very fast.