org.apache.lucene.index

## Class SortingLeafReader

- java.lang.Object
- - org.apache.lucene.index.IndexReader
  - - org.apache.lucene.index.LeafReader
    - - org.apache.lucene.index.FilterLeafReader
      - - org.apache.lucene.index.SortingLeafReader

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class SortingLeafReader
      extends FilterLeafReader

  An `LeafReader` which supports sorting documents by a given `Sort`. You can use this class to sort an index as follows:

       IndexWriter writer; // writer to which the sorted index will be added
       DirectoryReader reader; // reader on the input index
       Sort sort; // determines how the documents are sorted
       LeafReader sortingReader = SortingLeafReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sort);
       writer.addIndexes(reader);
       writer.close();
       reader.close();

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

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

      `FilterLeafReader.FilterFields, FilterLeafReader.FilterPostingsEnum, FilterLeafReader.FilterTerms, FilterLeafReader.FilterTermsEnum`

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

      `LeafReader.CoreClosedListener`

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

      `IndexReader.ReaderClosedListener`

  - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.index.FilterLeafReader

      `in`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `document(int docID, StoredFieldVisitor visitor)`
    `Fields` | `fields()`
    `BinaryDocValues` | `getBinaryDocValues(String field)`
    `Bits` | `getDocsWithField(String field)`
    `Bits` | `getLiveDocs()`
    `NumericDocValues` | `getNormValues(String field)`
    `NumericDocValues` | `getNumericDocValues(String field)`
    `SortedDocValues` | `getSortedDocValues(String field)`
    `SortedNumericDocValues` | `getSortedNumericDocValues(String field)`
    `SortedSetDocValues` | `getSortedSetDocValues(String field)`
    `Fields` | `getTermVectors(int docID)`
    `String` | `toString()`
    `static LeafReader` | `wrap(LeafReader reader, Sort sort)` Return a sorted view of `reader` according to the order defined by `sort`.

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

      `addCoreClosedListener, checkIntegrity, doClose, getDelegate, getFieldInfos, maxDoc, numDocs, removeCoreClosedListener, unwrap`

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

      `addCoreClosedListenerAsReaderClosedListener, docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, postings, postings, removeCoreClosedListenerAsReaderClosedListener, termDocsEnum, termPositionsEnum, terms, totalTermFreq`

    - ### 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`

- - ### Method Detail

    - #### wrap

          public static LeafReader wrap(LeafReader reader,
                        Sort sort)
                                 throws IOException

      Return a sorted view of `reader` according to the order defined by `sort`. If the reader is already sorted, this method might return the reader as-is.
      Throws:
        `IOException`

    - #### document

          public void document(int docID,
                      StoredFieldVisitor visitor)
                        throws IOException

      Overrides:
        `document` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### fields

          public Fields fields()
                        throws IOException

      Overrides:
        `fields` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getBinaryDocValues

          public BinaryDocValues getBinaryDocValues(String field)
                                             throws IOException

      Overrides:
        `getBinaryDocValues` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getLiveDocs

          public Bits getLiveDocs()

      Overrides:
        `getLiveDocs` in class `FilterLeafReader`

    - #### getNormValues

          public NumericDocValues getNormValues(String field)
                                         throws IOException

      Overrides:
        `getNormValues` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getNumericDocValues

          public NumericDocValues getNumericDocValues(String field)
                                               throws IOException

      Overrides:
        `getNumericDocValues` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getSortedNumericDocValues

          public SortedNumericDocValues getSortedNumericDocValues(String field)
                                                           throws IOException

      Overrides:
        `getSortedNumericDocValues` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getSortedDocValues

          public SortedDocValues getSortedDocValues(String field)
                                             throws IOException

      Overrides:
        `getSortedDocValues` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getSortedSetDocValues

          public SortedSetDocValues getSortedSetDocValues(String field)
                                                   throws IOException

      Overrides:
        `getSortedSetDocValues` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getDocsWithField

          public Bits getDocsWithField(String field)
                                throws IOException

      Overrides:
        `getDocsWithField` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### getTermVectors

          public Fields getTermVectors(int docID)
                                throws IOException

      Overrides:
        `getTermVectors` in class `FilterLeafReader`
      Throws:
        `IOException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `FilterLeafReader`

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