是否可以使用以下代码行来获取lucene索引或IndexWriter/SnapshotDeletionPolicy的热备份,如Lucene索引备份中所述?
Directory dir = ...;
IndexReader reader = IndexReader.open(dir);
IndexCommit commit = reader.getIndexCommit();
Collection<String> fileNames = commit.getFileNames();
//copy the files
reader.close();
Run Code Online (Sandbox Code Playgroud)
即使在锁定索引上,您也可以在提交点上打开读取器,而编写者可能仍会更改索引.
小智 2
如果没有 IndexWriter 写入索引,那么上面的代码就可以了。
但是针对索引的打开 IndexWriter 可以轻松删除此 IndexReader 引用/仍在使用的文件(例如,当合并完成时),然后您的备份将失败。
| 归档时间: |
|
| 查看次数: |
1047 次 |
| 最近记录: |