开发者

updating lucene index

开发者 https://www.devze.com 2022-12-30 04:50 出处:网络
What is the best way to update an existing Lucene index. I dont\'t just have to add/delete documents from it, rather u开发者_运维百科pdate the existing documents. You will have to open the index witho

What is the best way to update an existing Lucene index. I dont't just have to add/delete documents from it, rather u开发者_运维百科pdate the existing documents.


You will have to open the index without overwriting thus:

IndexWriter writer = new IndexWriter("MyIndexPath",analyzer, false);

The false flag at the end tells it to open in append mode.

The writer has an UpdateDocument method

writer.UpdateDocument(new Term("IDField",id), doc);

the id field should be some unique document identifier such as filename or file number etc.

0

精彩评论

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