如何释放所有 lucene .net 文件句柄?

发布于 2024-10-18 21:02:35 字数 300 浏览 7 评论 0原文

我想运行一个进程来完全销毁然后从头开始重建我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街角卖回忆 2024-10-25 21:02:35

您托管在 IIS 中吗?尝试 iisreset(有时 IIS 会保留文件本身)。

Are you hosted in IIS? Try an iisreset (sometimes IIS is holding onto the files themselves).

笔芯 2024-10-25 21:02:35

只需调用 IndexWriter.DeleteAll() ,然后调用 IndexWriter.Commit() ,它将删除索引内容,并使您能够从空索引开始,而已经开放的读者在关闭之前仍然能够读取数据。旧文件一旦不再使用,将自动删除。

Just call IndexWriter.DeleteAll() followed by a IndexWriter.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文