Search in sources :

Example 1 with DocSetBuilder

use of org.apache.solr.search.DocSetBuilder in project lucene-solr by apache.

the class SolrRangeQuery method createDocSet.

private DocSet createDocSet(SolrIndexSearcher searcher, long cost) throws IOException {
    int maxDoc = searcher.maxDoc();
    BitDocSet liveDocs = searcher.getLiveDocs();
    FixedBitSet liveBits = liveDocs.size() == maxDoc ? null : liveDocs.getBits();
    DocSetBuilder builder = new DocSetBuilder(maxDoc, cost);
    List<LeafReaderContext> leaves = searcher.getTopReaderContext().leaves();
    int maxTermsPerSegment = 0;
    for (LeafReaderContext ctx : leaves) {
        TermsEnum te = getTermsEnum(ctx);
        int termsVisited = builder.add(te, ctx.docBase);
        maxTermsPerSegment = Math.max(maxTermsPerSegment, termsVisited);
    }
    DocSet set = maxTermsPerSegment <= 1 ? builder.buildUniqueInOrder(liveBits) : builder.build(liveBits);
    return DocSetUtil.getDocSet(set, searcher);
}
Also used : BitDocSet(org.apache.solr.search.BitDocSet) FixedBitSet(org.apache.lucene.util.FixedBitSet) DocSetBuilder(org.apache.solr.search.DocSetBuilder) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) BitDocSet(org.apache.solr.search.BitDocSet) DocSet(org.apache.solr.search.DocSet) TermsEnum(org.apache.lucene.index.TermsEnum)

Aggregations

LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 TermsEnum (org.apache.lucene.index.TermsEnum)1 FixedBitSet (org.apache.lucene.util.FixedBitSet)1 BitDocSet (org.apache.solr.search.BitDocSet)1 DocSet (org.apache.solr.search.DocSet)1 DocSetBuilder (org.apache.solr.search.DocSetBuilder)1