public class MultiReader extends BaseCompositeReader<IndexReader>
CompositeReader which reads multiple indexes, appending
their content. It can be used to create a view on several
sub-readers (like DirectoryReader) and execute searches on it.
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: IndexReader instances 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 the
IndexReader instance; use your own
(non-Lucene) objects instead.
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener| Constructor and Description |
|---|
MultiReader(IndexReader... subReaders)
Construct a MultiReader aggregating the named set of (sub)readers.
|
MultiReader(IndexReader[] subReaders,
boolean closeSubReaders)
Construct a MultiReader aggregating the named set of (sub)readers.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
doClose()
Implements close.
|
IndexReader.CacheHelper |
getReaderCacheHelper()
Optional method: Return a
IndexReader.CacheHelper that can be used to cache
based on the content of this reader. |
docFreq, document, getDocCount, getSequentialSubReaders, getSumDocFreq, getSumTotalTermFreq, getTermVectors, maxDoc, numDocs, readerBase, readerIndex, totalTermFreqgetContext, toStringclose, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, tryIncRefpublic MultiReader(IndexReader... subReaders) throws IOException
Construct a MultiReader aggregating the named set of (sub)readers.
Note that all subreaders are closed if this Multireader is closed.
subReaders - set of (sub)readersIOExceptionpublic MultiReader(IndexReader[] subReaders, boolean closeSubReaders) throws IOException
Construct a MultiReader aggregating the named set of (sub)readers.
subReaders - set of (sub)readers; this array will be cloned.closeSubReaders - indicates whether the subreaders should be closed
when this MultiReader is closedIOExceptionpublic IndexReader.CacheHelper getReaderCacheHelper()
IndexReaderIndexReader.CacheHelper that can be used to cache
based on the content of this reader. Two readers that have different data
or different sets of deleted documents will be considered different.
A return value of null indicates that this reader is not suited
for caching, which is typically the case for short-lived wrappers that
alter the content of the wrapped reader.
getReaderCacheHelper in class IndexReaderprotected void doClose()
throws IOException
IndexReaderdoClose in class IndexReaderIOExceptionCopyright © 2000-2017 Apache Software Foundation. All Rights Reserved.