Class CompositeReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.CompositeReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
BaseCompositeReader
public abstract class CompositeReader extends IndexReader
Instances of this reader type can only be used to get stored fields from the underlying AtomicReaders, but it is not possible to directly retrieve postings. To do that, get theAtomicReaderContextfor all sub-readers viaIndexReader.leaves(). Alternatively, you can mimic anAtomicReader(with a serious slowdown), by wrapping composite readers withSlowCompositeReaderWrapper.IndexReader instances for indexes on disk are usually constructed with a call to one of the static
DirectoryReader.open()methods, e.g.DirectoryReader.open(Directory).DirectoryReaderimplements theCompositeReaderinterface, it is not possible to directly get postings.Concrete subclasses of IndexReader are usually constructed with a call to one of the static
open()methods, e.g.DirectoryReader.open(Directory).For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.
NOTE:
IndexReaderinstances are completely thread safe, meaning multiple threads can call any of its methods, concurrently. If your application requires external synchronization, you should not synchronize on theIndexReaderinstance; use your own (non-Lucene) objects instead.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompositeReaderContextgetContext()Expert: Returns the rootIndexReaderContextfor thisIndexReader's sub-reader tree.java.lang.StringtoString()-
Methods inherited from class org.apache.lucene.index.IndexReader
addReaderClosedListener, close, decRef, docFreq, document, document, document, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getDocCount, getRefCount, getSumDocFreq, getSumTotalTermFreq, getTermVector, getTermVectors, hasDeletions, hashCode, incRef, leaves, maxDoc, numDeletedDocs, numDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, totalTermFreq, tryIncRef
-
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getContext
public final CompositeReaderContext getContext()
Description copied from class:IndexReaderExpert: Returns the rootIndexReaderContextfor thisIndexReader's sub-reader tree.Iff this reader is composed of sub readers, i.e. this reader being a composite reader, this method returns a
CompositeReaderContextholding the reader's direct children as well as a view of the reader tree's atomic leaf contexts. All sub-IndexReaderContextinstances referenced from this readers top-level context are private to this reader and are not shared with another context tree. For example, IndexSearcher uses this API to drive searching by one atomic leaf reader at a time. If this reader is not composed of child readers, this method returns anAtomicReaderContext.Note: Any of the sub-
CompositeReaderContextinstances referenced from this top-level context do not supportCompositeReaderContext.leaves(). Only the top-level context maintains the convenience leaf-view for performance reasons.- Specified by:
getContextin classIndexReader
-
-