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删除指定记录
最新推荐文章于 2022-02-12 18:10:11 发布