org.apache.lucene.index

## Class ParallelCompositeReader

- java.lang.Object
- - org.apache.lucene.index.IndexReader
  - - org.apache.lucene.index.CompositeReader
    - - org.apache.lucene.index.BaseCompositeReader<LeafReader>
      - - org.apache.lucene.index.ParallelCompositeReader

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class ParallelCompositeReader
      extends BaseCompositeReader<LeafReader>

  An `CompositeReader` which reads multiple, parallel indexes. Each index added must have the same number of documents, and exactly the same number of leaves (with equal `maxDoc`), but typically each contains different fields. Deletions are taken from the first reader. Each document contains the union of the fields of all documents with the same document number. When searching, matches for a query term are from the first index added that has the field.

  This is useful, e.g., with collections that have large fields which change rarely and small fields that change more frequently. The smaller fields may be re-indexed in a new index and both indexes may be searched together.

  Warning: It is up to you to make sure all indexes are created and modified the same way. For example, if you add documents to one index, you need to add the same documents in the same order to the other indexes. Failure to do so will result in undefined behavior. A good strategy to create suitable indexes with `IndexWriter` is to use `LogDocMergePolicy`, as this one does not reorder documents during merging (like `TieredMergePolicy`) and triggers merges by number of documents per segment. If you use different `MergePolicy`s it might happen that the segment structure of your index is no longer predictable.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader

      `IndexReader.ReaderClosedListener`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ParallelCompositeReader(boolean closeSubReaders, CompositeReader... readers)` Create a ParallelCompositeReader based on the provided readers.
    `ParallelCompositeReader(boolean closeSubReaders, CompositeReader[] readers, CompositeReader[] storedFieldReaders)` Expert: create a ParallelCompositeReader based on the provided readers and storedFieldReaders; when a document is loaded, only storedFieldsReaders will be used.
    `ParallelCompositeReader(CompositeReader... readers)` Create a ParallelCompositeReader based on the provided readers; auto-closes the given readers on `IndexReader.close()`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doClose()` Implements close.

    - ### Methods inherited from class org.apache.lucene.index.BaseCompositeReader

      `docFreq, document, getDocCount, getSequentialSubReaders, getSumDocFreq, getSumTotalTermFreq, getTermVectors, 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, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, removeReaderClosedListener, tryIncRef`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ParallelCompositeReader

          public ParallelCompositeReader(CompositeReader... readers)
                                  throws IOException

      Create a ParallelCompositeReader based on the provided readers; auto-closes the given readers on `IndexReader.close()`.
      Throws:
        `IOException`

    - #### ParallelCompositeReader

          public ParallelCompositeReader(boolean closeSubReaders,
                                         CompositeReader... readers)
                                  throws IOException

      Create a ParallelCompositeReader based on the provided readers.
      Throws:
        `IOException`

    - #### ParallelCompositeReader

          public ParallelCompositeReader(boolean closeSubReaders,
                                         CompositeReader[] readers,
                                         CompositeReader[] storedFieldReaders)
                                  throws IOException

      Expert: create a ParallelCompositeReader based on the provided readers and storedFieldReaders; when a document is loaded, only storedFieldsReaders will be used.
      Throws:
        `IOException`

  - ### Method Detail

    - #### doClose

          protected void doClose()
                          throws IOException

      Description copied from class: `IndexReader`
      Implements close.
      Specified by:
        `doClose` in class `IndexReader`
      Throws:
        `IOException`

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