Interface IndexAccessor
- All Known Implementing Classes:
IndexAccessorImpl
public interface IndexAccessor
The entry point for low-level I/O operations on a Lucene index.
Used to retrieve the index writer and index reader in particular.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanUpAfterFailure(Throwable throwable, Object failingOperation) Closes, drops and re-creates any cached resources: index writers, index readers.voidcommit()Commits the underlying index writer, if any.voidCommits the underlying index writer, if any, or delay the commit if a commit happened recently and configuration requires to wait longer between two commits.longvoidChecks whether the index exists (on disk, ...), and creates it if necessary.voidChecks whether the index exists (on disk, ...), and drops it if it exists.org.apache.lucene.index.DirectoryReadervoidMerge segments files.voidrefresh()Refreshes the underlying index readers.voidChecks whether the index exists (on disk, ...), and throws an exception if it doesn't.
-
Method Details
-
createIndexIfMissing
void createIndexIfMissing()Checks whether the index exists (on disk, ...), and creates it if necessary. -
validateIndexExists
void validateIndexExists()Checks whether the index exists (on disk, ...), and throws an exception if it doesn't. -
dropIndexIfExisting
void dropIndexIfExisting()Checks whether the index exists (on disk, ...), and drops it if it exists. -
commit
void commit()Commits the underlying index writer, if any. -
commitOrDelay
void commitOrDelay()Commits the underlying index writer, if any, or delay the commit if a commit happened recently and configuration requires to wait longer between two commits. -
refresh
void refresh()Refreshes the underlying index readers. -
mergeSegments
void mergeSegments()Merge segments files. -
getIndexWriterDelegator
- Returns:
- The index writer delegator.
- Throws:
IOException
-
getIndexReader
- Returns:
- The most up-to-date index reader available.
- Throws:
IOException
-
cleanUpAfterFailure
Closes, drops and re-creates any cached resources: index writers, index readers.Should be used to clean up the accessor upon write or commit failure, passing an exception with as much information as possible (operation, document ID, ...).
- Parameters:
throwable- The failure.failingOperation- The operation that failed.
-
computeSizeInBytes
long computeSizeInBytes()- Returns:
- The size of the index on its storage support, in bytes.
-