Reputation: 1334
I am updating lucene index onec a day. My strategy in general is:
I have found that in lucene wiki: There is no direct update procedure in Lucene... I have found also that in lucene 4.1.0 doc: A document can be updated with updateDocument...
I have tried IndexWriter.updateDocument(Term, Document) but then performing search with filter I got NPE from one of my methods what not happens when I update index as describe in 1-4. Have anyone had a similar problem? How do you update your index?
Upvotes: 0
Views: 2608
Reputation: 20029
You might want to use a SearcherManager
to get new IndexSearchers as you update the index with a IndexWriter. I see no need for using a temporary index?
Upvotes: 0
Reputation: 24614
What I do is basically this:
I keep a persistent IndexReader/Readers, this will keep the state that it has since it was created.
I start to delete and create all documents once again. I think I just do a deleteAll() and then recreate them (addDocument()).
I commit, which will activate all those changes.
I drop all IndexReaders that I have, so the next time the system request a Reader, it will create it and store it for subsequent requests.
The updateDocument is basically a delete/create, afaik.
Upvotes: 1