PersistentSnapshotDeletionPolicy

A SnapshotDeletionPolicy which adds a persistence layer so that snapshots can be maintained across the life of an application. The snapshots are persisted in a Directory and are committed as soon as snapshot or release is called.

NOTE: Sharing [PersistentSnapshotDeletionPolicy]s that write to the same directory across [IndexWriter]s will corrupt snapshots. You should make sure every [IndexWriter] has its own [PersistentSnapshotDeletionPolicy] and that they all write to a different [Directory]. It is OK to use the same Directory that holds the index.

This class adds a [release] method to release commits from a previous snapshot's [IndexCommit.generation].

Constructors

Link copied to clipboard
constructor(primary: IndexDeletionPolicy, dir: Directory)

PersistentSnapshotDeletionPolicy wraps another IndexDeletionPolicy to enable flexible snapshotting, passing OpenMode.CREATE_OR_APPEND by default.

constructor(primary: IndexDeletionPolicy, dir: Directory, mode: IndexWriterConfig.OpenMode)

PersistentSnapshotDeletionPolicy wraps another IndexDeletionPolicy to enable flexible snapshotting.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Retrieve an IndexCommit from its generation; returns null if this IndexCommit is not currently snapshotted

Link copied to clipboard

Returns the file name the snapshots are currently saved to, or null if no snapshots have been saved.

Link copied to clipboard

Returns the total number of snapshots currently held.

Link copied to clipboard

Returns all IndexCommits held by at least one snapshot.

Link copied to clipboard
open override fun onCommit(commits: MutableList<out IndexCommit>)

This is called each time the writer completed a commit. This gives the policy a chance to remove old commit points with each commit.

Link copied to clipboard
open override fun onInit(commits: MutableList<out IndexCommit>)

This is called once when a writer is first instantiated to give the policy a chance to remove old commit points.

Link copied to clipboard
fun release(gen: Long)

Deletes a snapshotted commit by generation. Once this method returns, the snapshot information is persisted in the directory.

open override fun release(commit: IndexCommit)

Deletes a snapshotted commit. Once this method returns, the snapshot information is persisted in the directory.

Link copied to clipboard
open override fun snapshot(): IndexCommit

Snapshots the last commit. Once this method returns, the snapshot information is persisted in the directory.