private long innerCount() {
        try {
            final int maxDoc = searcher.maxDoc();
            if (maxDoc == 0) {
                return 0;
            }
            TotalHitCountCollector collector = new TotalHitCountCollector();
            searcher.search(createQuery(), getFilter(), collector);
            return collector.getTotalHits();
        } catch (IOException | IllegalArgumentException e) {
            throw new QueryException(e);
        }
    }
AbstractLuceneQuery is an abstract super class for Lucene query implementations

@author tiwe

@param <T> projection type
@param <Q> concrete subtype of query
querydsl-lucene3/src/main/java/com/querydsl/lucene3/AbstractLuceneQuery.java