Class SortingAtomicReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class SortingAtomicReader
    extends FilterAtomicReader
    An AtomicReader which supports sorting documents by a given Sorter. 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
     Sorter sorter; // determines how the documents are sorted
     AtomicReader sortingReader = SortingAtomicReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sorter);
     writer.addIndexes(reader);
     writer.close();
     reader.close();
     
    • Method Detail

      • wrap

        public static AtomicReader wrap​(AtomicReader reader,
                                        Sorter sorter)
                                 throws java.io.IOException
        Return a sorted view of reader according to the order defined by sorter. If the reader is already sorted, this method might return the reader as-is.
        Throws:
        java.io.IOException
      • fields

        public Fields fields()
                      throws java.io.IOException
        Description copied from class: AtomicReader
        Returns Fields for this reader. This method may return null if the reader has no postings.
        Overrides:
        fields in class FilterAtomicReader
        Throws:
        java.io.IOException
      • getLiveDocs

        public Bits getLiveDocs()
        Description copied from class: AtomicReader
        Returns the Bits representing live (not deleted) docs. A set bit indicates the doc ID has not been deleted. If this method returns null it means there are no deleted documents (all documents are live). The returned instance has been safely published for use by multiple threads without additional synchronization.
        Overrides:
        getLiveDocs in class FilterAtomicReader
      • getDocsWithField

        public Bits getDocsWithField​(java.lang.String field)
                              throws java.io.IOException
        Description copied from class: AtomicReader
        Returns a Bits at the size of reader.maxDoc(), with turned on bits for each docid that does have a value for this field, or null if no DocValues were indexed for this field. The returned instance should only be used by a single thread
        Overrides:
        getDocsWithField in class FilterAtomicReader
        Throws:
        java.io.IOException
      • getTermVectors

        public Fields getTermVectors​(int docID)
                              throws java.io.IOException
        Description copied from class: IndexReader
        Retrieve term vectors for this document, or null if term vectors were not indexed. The returned Fields instance acts like a single-document inverted index (the docID will be 0).
        Overrides:
        getTermVectors in class FilterAtomicReader
        Throws:
        java.io.IOException