I'll have to dig around in some collector code. I could swear that you could track the ord of the leaf this way at collection time. But there may be different code paths used then one I showed above.
Joel Bernstein http://joelsolr.blogspot.com/ On Sun, Dec 27, 2020 at 12:25 PM Haoyu Zhai <zhai7...@gmail.com> wrote: > Hi Joel, > LeafReader.getContext() is expected to return "the root IndexReaderContext > <https://lucene.apache.org/core/5_2_0/core/org/apache/lucene/index/IndexReaderContext.html> > for > this IndexReader > <https://lucene.apache.org/core/5_2_0/core/org/apache/lucene/index/IndexReader.html>'s > sub-reader tree." ( > https://lucene.apache.org/core/5_2_0/core/org/apache/lucene/index/LeafReader.html#getContext() > ) > Which means it will returns a context with ord 0 (a newly constructed, not > the previous one [1]) if it is already a leaf. So I think this is expected? > > [1]: > https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/index/LeafReader.java#L43 > > Best > Patrick > > Joel Bernstein <joels...@gmail.com> 于2020年12月27日周日 上午8:59写道: > >> I ran into this while writing some Solr code today. >> >> List<LeafReaderContext> leaves = >> req.getSearcher().getTopReaderContext().leaves(); >> >> The req is a SolrQueryRequest object. >> >> Now if I do this: >> >> leaves.get(5).reader().getContext().ord >> >> I would expect *ord* in this scenario to be *5*. >> >> But in my testing in master it's returning 0. >> >> It seems like this is a bug. Not sure yet if this is a bug in Sor or >> Lucene. Am I missing anything here that anyone can see? >> >> >> Joel Bernstein >> http://joelsolr.blogspot.com/ >> >