lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Closing indexsearcher , making sur eit is in use
Date Thu, 13 Jan 2011 20:55:44 GMT
Use something with reference counting - Lucene in action second
edition has a searcher manager class  which I think might be available
standalone.  Or a couple of low-tech alternatives: instead of closing
the old searcher, move it out of the way and keep a reference to it
and close it after n seconds or searches or whatever.  Or catch the
closed Exception and rerun the query with the up to date searcher.


--
Ian.


On Thu, Jan 13, 2011 at 8:21 PM, Paul Taylor <paul_t100@fastmail.fm> wrote:
> As recommended, I use just one Index Searcher on my multithreaded GUI app
> using a singleton pattern
> If data is modified in the index I then close the reader and searcher, and
> they will be recreate on next call to getInstance() but Ive hit a problem
> whereby one thread was closing a searcher, another thread already the
> searcher open but when came to use it gave exception 'the IndexReader is
> closed'
>
> I obviously dont want access to the searcher to be synchronized as it is
> designed to work multithreaded, so how should I close it safetly, i.e close
> if no current references to it.
>
> Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message