lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <yo...@apache.org>
Subject Re: Should I synchronize searching to cache the IndexSearcher?
Date Tue, 05 Jun 2007 13:08:22 GMT
On 6/5/07, Michael Böckling <Michael.Boeckling@dmc.de> wrote:
> In the docs it says that I should cache the IndexSearcher for best
> performance, and not build a new one for each query.
>
> The problem is that when I want to switch to a new index, I would have to
> synchronize my search() method while my update check runs (which is also
> synchronized), so searching and switching to a new index never happen at the
> same time.

You only have to synchronize handing out the searcher to another query
thread... the search method itself shouldn't need to be synchronized.
When a new searcher is opened, it can be handed to new request threads
while old request threads finish up with the old searcher... after the
old searcher is no longer used, close it (requires ref counting).

Check out how Solr does it: SolrCore.getSearcher() / registerSearcher()

-Yonik

---------------------------------------------------------------------
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