Search in sources :

Example 1 with DocSetCollector

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

the class CommandHandler method computeDocSet.

private DocSet computeDocSet(Query query, ProcessedFilter filter, List<Collector> collectors) throws IOException {
    int maxDoc = searcher.maxDoc();
    final DocSetCollector docSetCollector = new DocSetCollector(maxDoc);
    List<Collector> allCollectors = new ArrayList<>(collectors);
    allCollectors.add(docSetCollector);
    searchWithTimeLimiter(query, filter, MultiCollector.wrap(allCollectors));
    return DocSetUtil.getDocSet(docSetCollector, searcher);
}
Also used : ArrayList(java.util.ArrayList) DocSetCollector(org.apache.solr.search.DocSetCollector) TimeLimitingCollector(org.apache.lucene.search.TimeLimitingCollector) AllGroupHeadsCollector(org.apache.lucene.search.grouping.AllGroupHeadsCollector) MultiCollector(org.apache.lucene.search.MultiCollector) TotalHitCountCollector(org.apache.lucene.search.TotalHitCountCollector) Collector(org.apache.lucene.search.Collector) DocSetCollector(org.apache.solr.search.DocSetCollector)

Example 2 with DocSetCollector

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

the class BlockJoin method toParents.

/** childInput may also contain parents (i.e. a parent or below will all roll up to that parent) */
public static DocSet toParents(DocSet childInput, BitDocSet parentList, QueryContext qcontext) throws IOException {
    FixedBitSet parentBits = parentList.getBits();
    DocSetCollector collector = new DocSetCollector(qcontext.searcher().maxDoc());
    DocIterator iter = childInput.iterator();
    int currentParent = -1;
    while (iter.hasNext()) {
        // TODO: skipping
        int childDoc = iter.nextDoc();
        if (childDoc <= currentParent) {
            // we already visited this parent
            continue;
        }
        currentParent = parentBits.nextSetBit(childDoc);
        if (currentParent != DocIdSetIterator.NO_MORE_DOCS) {
            // only collect the parent the first time we skip to it
            collector.collect(currentParent);
        }
    }
    return collector.getDocSet();
}
Also used : DocIterator(org.apache.solr.search.DocIterator) FixedBitSet(org.apache.lucene.util.FixedBitSet) DocSetCollector(org.apache.solr.search.DocSetCollector)

Example 3 with DocSetCollector

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

the class BlockJoin method toChildren.

/** acceptDocs will normally be used to avoid deleted documents from being generated as part of the answer DocSet (just use *:*)
   *  although it can be used to further constrain the generated documents.
   */
public static DocSet toChildren(DocSet parentInput, BitDocSet parentList, DocSet acceptDocs, QueryContext qcontext) throws IOException {
    FixedBitSet parentBits = parentList.getBits();
    DocSetCollector collector = new DocSetCollector(qcontext.searcher().maxDoc());
    DocIterator iter = parentInput.iterator();
    while (iter.hasNext()) {
        int parentDoc = iter.nextDoc();
        if (!parentList.exists(parentDoc) || parentDoc == 0) {
            // not a parent, or parent has no children
            continue;
        }
        int prevParent = parentBits.prevSetBit(parentDoc - 1);
        for (int childDoc = prevParent + 1; childDoc < parentDoc; childDoc++) {
            // only select live docs
            if (acceptDocs != null && !acceptDocs.exists(childDoc))
                continue;
            collector.collect(childDoc);
        }
    }
    return collector.getDocSet();
}
Also used : DocIterator(org.apache.solr.search.DocIterator) FixedBitSet(org.apache.lucene.util.FixedBitSet) DocSetCollector(org.apache.solr.search.DocSetCollector)

Aggregations

DocSetCollector (org.apache.solr.search.DocSetCollector)3 FixedBitSet (org.apache.lucene.util.FixedBitSet)2 DocIterator (org.apache.solr.search.DocIterator)2 ArrayList (java.util.ArrayList)1 Collector (org.apache.lucene.search.Collector)1 MultiCollector (org.apache.lucene.search.MultiCollector)1 TimeLimitingCollector (org.apache.lucene.search.TimeLimitingCollector)1 TotalHitCountCollector (org.apache.lucene.search.TotalHitCountCollector)1 AllGroupHeadsCollector (org.apache.lucene.search.grouping.AllGroupHeadsCollector)1