lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: IndexReader / IndexWriter Synchronization
Date Tue, 25 Jul 2006 15:35:30 GMT

>   If I use IndexReader and IndexWriter class for inserts/updates, then I need to handle
the threading issues myself. Is there any other class (even in nightly build)  that I can
use without having to take care of synchronization.

All this means is your code must ensure only one "writer" (IndexWriter
adding docs or IndexReader removing docs) is open at a time.  If you
fail to do so, then the second "writer" you try to create will throw a
"Lock obtain timed out" IOException.

Otherwise these classes are fully thread safe.

The performance caveat in IndexModifier (that you should batch your
deletes and batch your adds) still applies, because you will need to
open/close an IndexReader for the former and an IndexWriter for the

The Lucene in Action book does a great job describing these
concurrency rules.

Also, you should first test IndexModifier to be really sure its
performance is not sufficient for your needs.


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

View raw message