diff --git a/solr/src/java/org/apache/solr/search/DocSet.java b/solr/src/java/org/apache/solr/search/DocSet.java index 32dc4f53e94..59b3286c98a 100644 --- a/solr/src/java/org/apache/solr/search/DocSet.java +++ b/solr/src/java/org/apache/solr/search/DocSet.java @@ -248,17 +248,14 @@ abstract class DocSetBase implements DocSet { return new Filter() { @Override public DocIdSet getDocIdSet(ReaderContext ctx) throws IOException { - int offset = 0; + IndexReader.AtomicReaderContext context = (IndexReader.AtomicReaderContext)ctx; // TODO: remove after lucene migration IndexReader reader = ctx.reader; - SolrIndexReader r = (SolrIndexReader)reader; - while (r.getParent() != null) { - offset += r.getBase(); - r = r.getParent(); + + if (context.isTopLevel) { + return bs; } - if (r==reader) return bs; - - final int base = offset; + final int base = context.docBase; final int maxDoc = reader.maxDoc(); final int max = base + maxDoc; // one past the max doc in this segment. diff --git a/solr/src/java/org/apache/solr/search/SortedIntDocSet.java b/solr/src/java/org/apache/solr/search/SortedIntDocSet.java index b0bb860407b..052bac50ef6 100755 --- a/solr/src/java/org/apache/solr/search/SortedIntDocSet.java +++ b/solr/src/java/org/apache/solr/search/SortedIntDocSet.java @@ -23,6 +23,7 @@ import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Filter; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader.ReaderContext; +import org.apache.lucene.index.IndexReader.AtomicReaderContext; import java.io.IOException; @@ -552,15 +553,11 @@ public class SortedIntDocSet extends DocSetBase { int lastEndIdx = 0; @Override - public DocIdSet getDocIdSet(ReaderContext context) throws IOException { - int offset = 0; + public DocIdSet getDocIdSet(ReaderContext contextX) throws IOException { + AtomicReaderContext context = (AtomicReaderContext)contextX; // TODO: remove after lucene migration IndexReader reader = context.reader; - SolrIndexReader r = (SolrIndexReader)reader; - while (r.getParent() != null) { - offset += r.getBase(); - r = r.getParent(); - } - final int base = offset; + + final int base = context.docBase; final int maxDoc = reader.maxDoc(); final int max = base + maxDoc; // one past the max doc in this segment. int sidx = Math.max(0,lastEndIdx); diff --git a/solr/src/test/org/apache/solr/search/TestDocSet.java b/solr/src/test/org/apache/solr/search/TestDocSet.java index 280e58d39ae..8a87ac5d72b 100644 --- a/solr/src/test/org/apache/solr/search/TestDocSet.java +++ b/solr/src/test/org/apache/solr/search/TestDocSet.java @@ -413,10 +413,15 @@ public class TestDocSet extends LuceneTestCase { Filter fa = a.getTopFilter(); Filter fb = b.getTopFilter(); + /*** top level filters are no longer supported // test top-level DocIdSet da = fa.getDocIdSet(topLevelContext); DocIdSet db = fb.getDocIdSet(topLevelContext); doTestIteratorEqual(da, db); + ***/ + + DocIdSet da; + DocIdSet db; // first test in-sequence sub readers for (ReaderContext readerInfo : topLevelContext.leaves()) {