Heres my issue, I perform add() to add documents to my index and then I close() it. That works great!
Now I have a new requirement and every time I save something in my DB I need to update my Index. I can't create again the indexWriter because it takes more than 4 minutes so I just need to update() or add() a document to the index.
To accomplish it, I'm not doing index.close(), I'm doing index.commit() after I populate my index... but i think it should be close and then open to update().
Any suggestion? THANKS!
close
is a costly operation and the javadocs recommended thatcommit
be used if you are updating frequently. The javadocs state thatclose
:I believe that the difference between
close
andcommit
is thatcommit
only flushes the data to make it visible to readers whereasclose
optimises the index too. This makescommit
about 5 times faster thanclose
.If you are adding data continuously, it is better to
commit
and then finallyclose
when you are all done.