lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert.Hasti...@ancept.com
Subject Re: how to safely periodically reopen the IndexReader?
Date Mon, 18 Feb 2008 17:08:13 GMT
We have the same situation and use an atomic counter.  Basically, we have 
a SearcherHolder class and a SearcherManager class.  The SearcherHolder 
holds the searcher and the number of threads referencing the searcher. 

When the thread that writes to the index closes the index, it sends an 
event that the SearcherManager is listening for.  The next time a search 
is performed the manager opens a new searcher.  The old searcher is marked 
as outdated but is not closed until the last thread that references the 
searcher returns it.





ZaeX <zaexage@gmail.com> 
02/16/2008 03:32 AM
Please respond to
java-user@lucene.apache.org


To
java-user@lucene.apache.org
cc

Subject
how to safely periodically reopen the IndexReader?






Hi, all

I've got a question here needing your help:
For my index, I opened one IndexWriter (autocommit mode) and one
IndexSearcher on it;
I have quite a lot of threads here concurrently writing new documents and
doing search in index.
the IndexWriter is flushed periodically.
as I want the IndexSearcher be able to see the latest record, I also need 
to
periodically reopen the underlying IndexReader.

But is it safe to just call close() on the IndexSearcher when there are
still threads using it?

or maybe I should use atomic counter to make sure there's no thread using 
it
before calling close() on IndexSearcher?

thanks.


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