@Override
    public void collect(final int doc) {
        final int docId = docBase + doc;
        docIdList.add(docId);

        if (docIdList.size() >= maxHits) {
            throw new SearchException("Max hits exceeded!");
        }
    }
Collect results until we hit the max.
stroom-index/stroom-index-lucene553/src/main/java/stroom/index/lucene553/MaxHitCollector.java