Class MultiReader

  extended by org.apache.lucene.index.IndexReader
      extended by org.apache.lucene.index.CompositeReader
          extended by org.apache.lucene.index.BaseCompositeReader<IndexReader>
              extended by org.apache.lucene.index.MultiReader
All Implemented Interfaces:

public class MultiReader
extends BaseCompositeReader<IndexReader>

A 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.

Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
Constructor Summary
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.
Method Summary
protected  void doClose()
          Implements close.
Methods inherited from class org.apache.lucene.index.BaseCompositeReader
docFreq, document, getSequentialSubReaders, getTermVectors, hasDeletions, maxDoc, numDocs, readerBase, readerIndex, totalTermFreq
Methods inherited from class org.apache.lucene.index.CompositeReader
getContext, toString
Methods inherited from class org.apache.lucene.index.IndexReader
addReaderClosedListener, close, decRef, document, document, ensureOpen, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hashCode, incRef, leaves, numDeletedDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Constructor Detail


public MultiReader(IndexReader... subReaders)

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)readers


public MultiReader(IndexReader[] subReaders,
                   boolean closeSubReaders)

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 closed
Method Detail


protected void doClose()
                throws IOException
Description copied from class: IndexReader
Implements close.

Specified by:
doClose in class IndexReader

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.