open

fun open(directory: Directory): DirectoryReader

Returns a IndexReader reading the index in the given Directory

Parameters

directory

the index directory

Throws

IOException

if there is a low-level IO error


fun open(directory: Directory, leafSorter: Comparator<LeafReader>): DirectoryReader

Returns a IndexReader for the index in the given Directory

Parameters

directory

the index directory

leafSorter

a comparator for sorting leaf readers. Providing leafSorter is useful for indices on which it is expected to run many queries with particular sort criteria (e.g. for time-based indices this is usually a descending sort on timestamp). In this case leafSorter should sort leaves according to this sort criteria. Providing leafSorter allows to speed up this particular type of sort queries by early terminating while iterating through segments and segments' documents.

Throws

IOException

if there is a low-level IO error


fun open(writer: IndexWriter, applyAllDeletes: Boolean = true, writeAllDeletes: Boolean = false): DirectoryReader

Open a near real time IndexReader from the IndexWriter.

Return

The new IndexReader

Parameters

writer

The IndexWriter to open from

See also

.openIfChanged

Throws

if the index is corrupt

IOException

if there is a low-level IO error


Expert: returns an IndexReader reading the index in the given IndexCommit.

Parameters

commit

the commit point to open

Throws

IOException

if there is a low-level IO error


fun open(commit: IndexCommit, minSupportedMajorVersion: Int, leafSorter: Comparator<LeafReader>): DirectoryReader

Expert: returns an IndexReader reading the index on the given IndexCommit. This method allows to open indices that were created with a Lucene version older than N-1 provided that all codecs for this index are available in the classpath and the segment file format used was created with Lucene 7 or newer. Users of this API must be aware that Lucene doesn't guarantee semantic compatibility for indices created with versions older than N-1. All backwards compatibility aside from the file format is optional and applied on a best effort basis.

Parameters

commit

the commit point to open

minSupportedMajorVersion

the minimum supported major index version

leafSorter

a comparator for sorting leaf readers. Providing leafSorter is useful for indices on which it is expected to run many queries with particular sort criteria (e.g. for time-based indices, this is usually a descending sort on timestamp). In this case leafSorter should sort leaves according to this sort criteria. Providing leafSorter allows to speed up this particular type of sort queries by early terminating while iterating through segments and segments' documents

Throws

IOException

if there is a low-level IO error