如何释放所有 lucene .net 文件句柄?
我想运行一个进程来完全销毁然后从头开始重建我的 lucene .net 搜索索引。
破坏部分
我被困在我所说的
: IndexWriter.Commit(); IndexWriter.Close(); 分析器.Close(); foreach (Directory.ListAll() 中的 var name) { Directory.ClearLock(name);目录.DeleteFile(名称); } 目录.关闭();
但该过程失败,因为它仍然是文件“_0.cfs”上的文件处理程序
有什么想法吗?
I want to run a process that completely destroys and then rebuilds my lucene .net search index from scratch.
I'm stuck on the destroying part
I've called:
IndexWriter.Commit();
IndexWriter.Close();
Analyzer.Close();
foreach (var name in Directory.ListAll()) { Directory.ClearLock(name); Directory.DeleteFile(name); }
Directory.Close();
but the process is failing because the is still a file handler on a file '_0.cfs'
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您托管在 IIS 中吗?尝试
iisreset
(有时 IIS 会保留文件本身)。Are you hosted in IIS? Try an
iisreset
(sometimes IIS is holding onto the files themselves).只需调用
IndexWriter.DeleteAll()
,然后调用IndexWriter.Commit()
,它将删除索引内容,并使您能够从空索引开始,而已经开放的读者在关闭之前仍然能够读取数据。旧文件一旦不再使用,将自动删除。Just call
IndexWriter.DeleteAll()
followed by aIndexWriter.Commit()
, it will remove the index content and will enable you to start off with an empty index, while already open readers will still be able to read data until closed. The old files will automatically be removed once they are no longer used.