lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy" <>
Subject RE: thread safety
Date Fri, 02 Apr 2010 23:00:14 GMT
A sample app. may be as below. (in Lucene.Net 2.9.x)


IndexWriter singletonIndexWriter;


void IndexerThread()






             if(needed) singletonIndexWriter.Commit();




//Called by different threads. No "lock" is needed!

void Search()


       IndexSearcher src = new IndexSearcher(
singletonIndexWriter.GetReader() );








-----Original Message-----
From: emagdnim paradox [] 
Sent: Saturday, April 03, 2010 1:10 AM
Subject: Re: thread safety


So is the problem something like:


if (!reader.IsCurrent) {

//Other thread closes reader

reader.ReOpen(); //fails because reader is now closed





Does IndexSearcher do this automatically, or can I just know that when I
refresh the reader I need to lock it first? Or are you saying that there are
additional difficulties with using indexsearcher?





----- Original Message ----

From: Franklin Simmons <>

To: "" <>

Sent: Fri, April 2, 2010 3:24:41 PM

Subject: RE: thread safety


You will run into trouble using a singleton IndexSearcher.  Use a singleton
IndexReader, and create IndexSearcher's on demand.  


You would need to synchronize the singleton IndexReader for a dynamic index
employing IndexReader.IsCurrent / IndexReader.ReOpen to keep search results
up to date.


-----Original Message-----

From: emagdnim paradox [] 

Sent: Friday, April 02, 2010 1:54 PM


Subject: thread safety




I'm having difficulty understanding what pieces of lucene are thread safe.
The index searcher documentation, for example, says "Instance members are
not guaranteed to be  thread-safe."


If I have a singleton index searcher that my whole process can access, can
the threads access it without locking? Are there any examples of using in a multi-threaded app I could look at?







  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message