Lucene之刪除索引(備忘)

2021-09-08 16:00:03 字數 831 閱讀 1202

如果想刪除lucene索引,常常採用的類是indexwriter,下圖描述indexwriter類刪除索引的方法:

ok,我來測試這個deleteall方法是什麼效果。首先建立一些索引檔案(具體的方法和**我就此省略),索引檔案可以組織結構圖如下:

接下來,我們來將索引刪除,以前刪除索引我都是手動刪除,汗~~~~,因為那些索引建立了以後幾乎都不改變,因為那些資料都是不動的興趣點資料。所以我當時也沒有寫刪除索引的方法。下面是我測試刪除索引的方法:

1

public

void testdeleteindex());

5 config.setqueryfields(new string);

6 config.settablename("t_goverment");

7try catch (corruptindexexception e) catch (lockobtainfailedexception e) catch (ioexception e)

23 };

來看看刪除索引有什麼效果,是不是全部的檔案都刪除了?

怎麼還剩下兩個檔案沒有刪除呢?到底是什麼原因,繼續試試其他方法吧!

lucene 索引刪除

1.indexwriter和indexreader都有刪除索引的方法 deletedocuments 不建議使用indexreader刪除索引 使用indexreader進行刪除時,必須關閉所有已經開啟的indexwriter 當使用當前的indexreader進行搜尋時,即使在不關閉indexre...

lucene中的刪除索引

今天在測試lucene的刪除索引中遇到乙個問題 測試 如下 protected void setup throws exception public void testdeleteindex throws exception 在測試中,首先重建索引 見setup方法 在測試方法中可以看出 1 刪除前...

lucene中的刪除索引

今天在測試lucene的刪除索引中遇到乙個問題 測試 如下 protected void setup throws exception public void testdeleteindex throws exception 在測試中,首先重建索引 見setup方法 在測試方法中可以看出 1 刪除前...