删除Lucene.net中的所有索引 [英] Delete all indices in Lucene.net
本文介绍了删除Lucene.net中的所有索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除所有先前创建的索引.我正在使用Lucene.net
.
I want to delete all the previously created indices. I am using Lucene.net
.
我尝试了以下操作:
Term term = new Term(); //empty because I want to delete all the indices
IndexReader rdr = IndexReader.Open(_directory);
rdr.DeleteDocuments(term);
rdr.Close();
但是我得到了错误.知道怎么做吗?
But I get error. Any idea how to go about it?
推荐答案
删除索引的最佳方法是擦除文件系统目录.但是,如果您不想重新生成索引,最简单的方法是使用create参数为true打开一个新的索引编写器.它将启动一个新索引,删除现有索引的内容.
The best way to delete an index is to wipe the filesystem directory. However, if you wan't to regenerate the index, the easiest way is to open a new indexwriter with the create parameter as true. It will start a new index deleting the contents of the existing one.
这篇关于删除Lucene.net中的所有索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文