Search in sources :

Example 1 with AggregatableDocIter

use of org.apache.solr.search.join.BlockJoinFieldFacetAccumulator.AggregatableDocIter in project lucene-solr by apache.

the class BlockJoinDocSetFacetComponent method process.

@Override
public void process(ResponseBuilder rb) throws IOException {
    final BlockJoinParentQParser.AllParentsAware bjq = (BlockJoinParentQParser.AllParentsAware) rb.req.getContext().get(bjqKey);
    if (bjq != null) {
        final DocSet parentResult = rb.getResults().docSet;
        final BitDocSet allParentsBitsDocSet = rb.req.getSearcher().getDocSetBits(bjq.getParentQuery());
        final DocSet allChildren = BlockJoin.toChildren(parentResult, allParentsBitsDocSet, rb.req.getSearcher().getDocSetBits(new MatchAllDocsQuery()), QueryContext.newContext(rb.req.getSearcher()));
        final DocSet childQueryDocSet = rb.req.getSearcher().getDocSet(bjq.getChildQuery());
        final DocSet selectedChildren = allChildren.intersection(childQueryDocSet);
        // don't include parent into facet counts
        //childResult = childResult.union(parentResult);// just to mimic the current logic
        final List<LeafReaderContext> leaves = rb.req.getSearcher().getIndexReader().leaves();
        Filter filter = selectedChildren.getTopFilter();
        final BlockJoinFacetAccsHolder facetCounter = new BlockJoinFacetAccsHolder(rb.req);
        for (int subIdx = 0; subIdx < leaves.size(); subIdx++) {
            LeafReaderContext subCtx = leaves.get(subIdx);
            // solr docsets already exclude any deleted docs
            DocIdSet dis = filter.getDocIdSet(subCtx, null);
            AggregatableDocIter iter = new SegmentChildren(subCtx, dis, allParentsBitsDocSet);
            if (iter.hasNext()) {
                facetCounter.doSetNextReader(subCtx);
                facetCounter.countFacets(iter);
            }
        }
        facetCounter.finish();
        rb.req.getContext().put(COLLECTOR_CONTEXT_PARAM, facetCounter);
        super.process(rb);
    }
}
Also used : AggregatableDocIter(org.apache.solr.search.join.BlockJoinFieldFacetAccumulator.AggregatableDocIter) DocIdSet(org.apache.lucene.search.DocIdSet) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) BitDocSet(org.apache.solr.search.BitDocSet) Filter(org.apache.solr.search.Filter) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) BitDocSet(org.apache.solr.search.BitDocSet) DocSet(org.apache.solr.search.DocSet)

Aggregations

LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 DocIdSet (org.apache.lucene.search.DocIdSet)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1 BitDocSet (org.apache.solr.search.BitDocSet)1 DocSet (org.apache.solr.search.DocSet)1 Filter (org.apache.solr.search.Filter)1 AggregatableDocIter (org.apache.solr.search.join.BlockJoinFieldFacetAccumulator.AggregatableDocIter)1