lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: when to refresh IndexSearcher and IndexWriter
Date Thu, 28 Aug 2008 11:15:27 GMT

Ganesh - yahoo wrote:

> Hello all,
>
> My index will get update very frequently.
>
> 1) When shall i need to optimize IndexWriter? I have planned to  
> optimize every day. Is that fine.

Probably you should test in your app, to see if optimization is even  
necessary and if so, at what frequency.  Optimize() is quite costly in  
IO and if done on the same machine doing searches will likely slow  
down the searches.

> 2) When shall i need to re-open IndexReader and IndexSearcher? I  
> have planned to do it every 10 minutes.

This is your design choice: how costly is it when your users receive  
stale results?  How frequently do you add/update docs to the index?

> 3) IndexSearcher could be used across threads. If i have to re-open  
> the IndexReader and IndexSearcher, then it should be synchronized.  
> If i try to do this then i am ending up in doing complete search  
> functionality in synchronization. Is there any better way to do that.
>
> synchronized void search() {

You can continue to use the old searcher even while a new IndexReader  
is being reopened, so, searches need not be synchronized.

However, once the reopen finishes (and, any warming that you need to  
do completes) the "swap out" of the old searcher for the new one must  
be done carefully such that new searches immediately start using the  
new searcher, and you do not close the old searcher until all running  
searches are done with it.

Mike

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