开发者

How do I release all lucene .net file handles?

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 t开发者_如何学Gohe is still a file handler on a file '_0.cfs'

Any ideas?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜