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 <[email protected]> 于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/
>

Reply via email to