You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by J B <jh...@gmail.com> on 2008/03/11 11:31:56 UTC

IndexSearcher thread safety

Hi,

Are instances of IndexSearcher thread safe? In other words, should each
thread have it's own instance of IndexSearcher, or could I share a single
one between many threads, to avoid constantly opening and closing new
instances?

Many thanks!
-J.

Re: IndexSearcher thread safety

Posted by German Kondolf <ge...@gmail.com>.
As Michael said, you can share it, and you should share it, this will
improve performance and reuse the internal cache associated to the
IndexSearcher (term cache, filters cache, etc).

On Tue, Mar 11, 2008 at 7:31 AM, J B <jh...@gmail.com> wrote:
> Hi,
>
>  Are instances of IndexSearcher thread safe? In other words, should each
>  thread have it's own instance of IndexSearcher, or could I share a single
>  one between many threads, to avoid constantly opening and closing new
>  instances?
>
>  Many thanks!
>  -J.
>

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


Re: IndexSearcher thread safety

Posted by Michael McCandless <lu...@mikemccandless.com>.
They are thread safe.  You should share a single instance across  
multiple threads.

Mike

J B wrote:

> Hi,
>
> Are instances of IndexSearcher thread safe? In other words, should  
> each
> thread have it's own instance of IndexSearcher, or could I share a  
> single
> one between many threads, to avoid constantly opening and closing new
> instances?
>
> Many thanks!
> -J.


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