Stopwatch sw = new Stopwatch();
// 啟動計時器
sw.Start();
string indexPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\Index1\\";
DirectoryInfo dirInfo = new DirectoryInfo(indexPath);
FSDirectory dir = FSDirectory.Open(dirInfo);
// 讀取 index file
IndexReader reader = IndexReader.Open(dir, false);
// 透過 Term 敘述當 Id 是 9 的資料透過 IndexReader 去刪除
reader.DeleteDocuments(new Term("Id", "9"));
reader.Close();
sw.Stop();
Response.Write("刪除指定索引花費時間: " + sw.Elapsed + "");lucene.net删除指定记录
最新推荐文章于 2021-12-17 10:56:27 发布
本文通过一个具体的示例介绍了如何使用Lucene在.NET环境下删除特定ID的索引文件。示例中首先启动了一个计时器,然后打开了指定目录下的索引文件,并通过IndexReader删除了ID为9的数据,最后输出了整个操作所花费的时间。
152

被折叠的 条评论
为什么被折叠?



