0
votes

I don't understand this problem about Lucene indexwriter. After I open the indexwriter, add a few new documents, then close it. Reopen the indexwriter using the same directory, add a few new documents. Then all previous documents are gone. I just could not figure it out why it behaves like that.

1
that'd never happen. Did you make sure that the directory contains index having some content after the 1st write operation? You may try using Luke to study the same or just check the size of the directory.phanin
Phani, thanks. You are very helpful. Silly me, I did not set the deletePolicy to false.Zincup
Are you refering the the create argument to the IndexWriter ctor (replaced by IndexWriterConfig.OpenMode in later versions)? Or are you actually refering to an IndexDeletionPolicy?femtoRgon

1 Answers

0
votes

As Zincup notes above, you need to set deletePolicy to false when adding documents to an existing index. (Added here so this question has a formal answer.)