-
1 Flush any buffered documents and deletions.
-
2 Sync all newly created files, including newly flushed files as well as any files produced by merges that have finished since commit was last called or since the IndexWriter was opened. IndexWriter calls Directory.sync to achieve this,
which doesn’t return until all pending writes in the specified file have been writ-
ten to stable storage on the underlying I/O system. This is usually a costly oper-
ation as it forces the OS to flush any pending writes. Different file systems also
show wide variance in the cost of this operation.
3 Write and sync the next segments_N file. Once this completes, IndexReaders will suddenly see all changes done since the last commit.
4 Remove old commits by calling on IndexDeletionPolicy to remove old com- mits. You can create your own implementation of this class to customize which commits are deleted, and when.
INDEXDELETIONPOLICY
IndexDeletionPolicy is the class that tells IndexWriter when it’s safe to remove old commits. The default policy is KeepOnlyLastCommitDeletionPolicy, which always removes all prior commits whenever a new commit is complete. Most of the time you should use this default. But for some advanced applications where you’d like to keep an old point-in-time snapshot around even though further changes have been com- mitted to the index, you may implement your own policy.
For example, when you’re sharing an index over NFS, it may be necessary to cus- tomize the deletion policy so that a commit isn’t deleted until all readers using the index have switched to the most recent commit, based on application specific logic (see section 2.11.2 for details). Another example is a retail company that would like to keep the last N versions of its catalog available for searching. Note that whenever your policy chooses to keep a commit around, that commit will necessarily consume addi- tional disk space in the index.
전체 페이지뷰
2013년 7월 27일 토요일
Index commits
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기