Package org.apache.lucene.index
Class ReaderUtil
java.lang.Object
org.apache.lucene.index.ReaderUtil
Common util methods for dealing with
IndexReaders and IndexReaderContexts.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IndexReaderContextgetTopLevelContext(IndexReaderContext context) Walks up the reader tree and return the given context's top level reader context, or in other words the reader tree's root context.static int[][]partitionByLeaf(ScoreDoc[] hits, List<LeafReaderContext> leaves) Partitions global doc IDs from ScoreDoc array by leaf.static intsubIndex(int n, int[] docStarts) Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader.static intsubIndex(int n, List<LeafReaderContext> leaves) Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader.
-
Method Details
-
getTopLevelContext
Walks up the reader tree and return the given context's top level reader context, or in other words the reader tree's root context. -
subIndex
public static int subIndex(int n, int[] docStarts) Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader. -
subIndex
Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader. -
partitionByLeaf
Partitions global doc IDs from ScoreDoc array by leaf. Extracts doc IDs, sorts them, and partitions across leaves.- Parameters:
hits- the ScoreDoc array (typically from TopDocs.scoreDocs)leaves- the index reader's leaves- Returns:
- array indexed by leaf ord, containing global doc IDs for that leaf (empty if no hits)
-