lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ankum <>
Subject Lucene Incremental Update to indexes
Date Tue, 06 Jan 2015 00:13:44 GMT

I did few searches around incremental updates, but found outdated posts, so
just want to ensure I use the correct solution with the latest and greatest
of Lucene API's and knowledge from experts.


I have a large index of documents (say 4 million, each with unique
application id's) - and I have need to frequently update this original
'main' index with 'delta' - for add, update, and delete. 

My strategy for updating the main index, for this delta index is (my test

 - read the delta index (worst case 1 million documents)
 - each document in this delta index, will have an flag to identify
 - for each such document call the appropriate API on the main index (opened
in OpenMode.APPEND) :
    - addDocument(doc)
    - updateDocument(new Term(ID, id), doc)
    - deleteDocuments(new Term(ID, id))
- do a writer.close() on the main index
- do DirectoryReader newReader = DirectoryReader.openIfChanged(mainReader) 
- if newReader above is != null, then I initialize the indexSearcher with
the newReader, and do mainReader.close (the old reader)

Does anyone feel above is best approach? Or it should be handled differently
(code issues, performance bottlenecks)

Thanks in advance !


View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message