tags:

views:

45

answers:

1

Hi everyone,

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!

+5  A: 

close is a costly operation and the javadocs recommended that commit be used if you are updating frequently. The javadocs state that close:

Commits all changes to an index and closes all associated files. Note that this may be a costly operation, so, try to re-use a single writer instead of closing and opening a new one.

I believe that the difference between close and commit is that commit only flushes the data to make it visible to readers whereas close optimises the index too. This makes commit about 5 times faster than close.

If you are adding data continuously, it is better to commit and then finally close when you are all done.

dogbane
Thanks a lot, I was thinking the same but I was open for second opinions!
orlandoMG