Lucene index update

What is the best way to update an existing Lucene index. I just do not need to add / remove documents from it, but update existing documents.

+6
lucene
source share
1 answer

You will need to open the index without overwriting this way:

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

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

The author has an UpdateDocument method

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

the id field must be a unique identifier for the document, such as a file name or file number, etc.

+11
source share

All Articles