Package org.apache.lucene.index.sorter
Class SortingAtomicReader
java.lang.Object
org.apache.lucene.index.IndexReader
org.apache.lucene.index.AtomicReader
org.apache.lucene.index.FilterAtomicReader
org.apache.lucene.index.sorter.SortingAtomicReader
- All Implemented Interfaces:
Closeable,AutoCloseable
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();
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.FilterAtomicReader
FilterAtomicReader.FilterDocsAndPositionsEnum, FilterAtomicReader.FilterDocsEnum, FilterAtomicReader.FilterFields, FilterAtomicReader.FilterTerms, FilterAtomicReader.FilterTermsEnumNested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener -
Method Summary
Modifier and TypeMethodDescriptionvoiddocument(int docID, StoredFieldVisitor visitor) Expert: visits the fields of a stored document, for custom processing/loading of each field.fields()ReturnsFieldsfor this reader.getBinaryDocValues(String field) ReturnsBinaryDocValuesfor this field, or null if noBinaryDocValueswere indexed for this field.getDocsWithField(String field) Returns aBitsat the size ofreader.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.Returns theBitsrepresenting live (not deleted) docs.getNormValues(String field) ReturnsNumericDocValuesrepresenting norms for this field, or null if noNumericDocValueswere indexed.getNumericDocValues(String field) ReturnsNumericDocValuesfor this field, or null if noNumericDocValueswere indexed for this field.getSortedDocValues(String field) ReturnsSortedDocValuesfor this field, or null if noSortedDocValueswere indexed for this field.getSortedSetDocValues(String field) ReturnsSortedSetDocValuesfor this field, or null if noSortedSetDocValueswere indexed for this field.getTermVectors(int docID) Retrieve term vectors for this document, or null if term vectors were not indexed.static AtomicReaderwrap(AtomicReader reader, Sorter sorter) Return a sorted view ofreaderaccording to the order defined bysorter.static AtomicReaderwrap(AtomicReader reader, Sorter.DocMap docMap) Expert: same aswrap(AtomicReader, Sorter)but operates directly on aSorter.DocMap.Methods inherited from class org.apache.lucene.index.FilterAtomicReader
getFieldInfos, maxDoc, numDocs, toStringMethods inherited from class org.apache.lucene.index.AtomicReader
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, hasNorms, termDocsEnum, termPositionsEnum, terms, totalTermFreqMethods inherited from class org.apache.lucene.index.IndexReader
addReaderClosedListener, close, decRef, document, document, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
-
Method Details
-
wrap
Return a sorted view ofreaderaccording to the order defined bysorter. If the reader is already sorted, this method might return the reader as-is.- Throws:
IOException
-
wrap
Expert: same aswrap(AtomicReader, Sorter)but operates directly on aSorter.DocMap. -
document
Description copied from class:IndexReaderExpert: visits the fields of a stored document, for custom processing/loading of each field. If you simply want to load all fields, useIndexReader.document(int). If you want to load a subset, useDocumentStoredFieldVisitor.- Overrides:
documentin classFilterAtomicReader- Throws:
IOException
-
fields
Description copied from class:AtomicReaderReturnsFieldsfor this reader. This method may return null if the reader has no postings.- Overrides:
fieldsin classFilterAtomicReader- Throws:
IOException
-
getBinaryDocValues
Description copied from class:AtomicReaderReturnsBinaryDocValuesfor this field, or null if noBinaryDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getBinaryDocValuesin classFilterAtomicReader- Throws:
IOException
-
getLiveDocs
Description copied from class:AtomicReaderReturns theBitsrepresenting 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:
getLiveDocsin classFilterAtomicReader
-
getNormValues
Description copied from class:AtomicReaderReturnsNumericDocValuesrepresenting norms for this field, or null if noNumericDocValueswere indexed. The returned instance should only be used by a single thread.- Overrides:
getNormValuesin classFilterAtomicReader- Throws:
IOException
-
getNumericDocValues
Description copied from class:AtomicReaderReturnsNumericDocValuesfor this field, or null if noNumericDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getNumericDocValuesin classFilterAtomicReader- Throws:
IOException
-
getSortedDocValues
Description copied from class:AtomicReaderReturnsSortedDocValuesfor this field, or null if noSortedDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedDocValuesin classFilterAtomicReader- Throws:
IOException
-
getSortedSetDocValues
Description copied from class:AtomicReaderReturnsSortedSetDocValuesfor this field, or null if noSortedSetDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedSetDocValuesin classFilterAtomicReader- Throws:
IOException
-
getDocsWithField
Description copied from class:AtomicReaderReturns aBitsat the size ofreader.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:
getDocsWithFieldin classFilterAtomicReader- Throws:
IOException
-
getTermVectors
Description copied from class:IndexReaderRetrieve 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:
getTermVectorsin classFilterAtomicReader- Throws:
IOException
-