How to count all tokens count in an collection/index
<p>I use Lucene 5.3.1 and I've already indexed some documents and now am trying to find a built-in function to count <strong>all tokens count</strong> (across the collection/index)</p>

<p>I know that I can iterate over all documents and make a sum on their length. But because of my complex algorithms that increases run time, I'm trying to avoid this approach. I think lucene maybe have an api for this...</p>

<p>After all, I googled this function (or any similar function), But I cannot find any useful link.</p>

<p>Now the question is: Is there any built-in function which returns <strong>number of ALL TOKENS in collection</strong> (i.e. whole index) ?? If not, Is there any other optimum approach?</p>

<p>Any help is appreciated, thanks.</p>