Companion

object Companion

Functions

Link copied to clipboard
fun indexExists(directory: Directory): Boolean

Returns true if an index likely exists at the specified directory. Note that if a corrupt index exists, or if an index in the process of committing the return value is not reliable.

Link copied to clipboard

Returns all commit points that exist in the Directory. Normally, because the default is [ ], there would be only one commit point. But if you're using a custom IndexDeletionPolicy then there could be many commits. Once you have a given commit, you can open a reader on it by calling DirectoryReader.open There must be at least one commit in the Directory, else this method throws [ ]. Note that if a commit is in progress while this method is running, that commit may or may not be returned.

Link copied to clipboard

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

fun open(directory: Directory): DirectoryReader

Returns a IndexReader reading the index in the given Directory

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

Returns a IndexReader for the index in the given Directory

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.

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

Open a near real time IndexReader from the IndexWriter.

Link copied to clipboard

If the index has changed since the provided reader was opened, open and return a new reader; else, return null. The new reader, if not null, will be the same type of reader as the previous one, ie an NRT reader will open a new NRT reader etc.

If the IndexCommit differs from what the provided reader is searching, open and return a new reader; else, return null.

fun openIfChanged(oldReader: DirectoryReader, writer: IndexWriter, applyAllDeletes: Boolean = true): DirectoryReader?

Expert: If there changes (committed or not) in the IndexWriter versus what the provided reader is searching, then open and return a new IndexReader searching both committed and uncommitted changes from the writer; else, return null (though, the current implementation never returns null).