You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Artem Chereisky <a....@gmail.com> on 2010/01/13 23:08:23 UTC
IndexSearcher - re-use or not re-use
Hi,
according to the documentation, IndexSearcher is thread and process safe so
it's ok to use the same searcher in a multi-threaded application (in my case
it's a windows service executing multiple requests at the same time). But,
what are the pros and cons for re-using the searcher? What do you guys
usually do in your apps and why?
Thanks,
Art
Re: IndexSearcher - re-use or not re-use
Posted by Simone Chiaretta <si...@gmail.com>.
If you are using the 2.9.1 you can use the IndexWriter.GetReader() method
which does everything for you: this way you need to keep only the
indexwriter around.
I use this approach with the application I'm using
Simone
On Mon, Jan 18, 2010 at 12:32 AM, Grant Ingersoll <gs...@apache.org>wrote:
>
> On Jan 13, 2010, at 5:08 PM, Artem Chereisky wrote:
>
> > Hi,
> >
> > according to the documentation, IndexSearcher is thread and process safe
> so
> > it's ok to use the same searcher in a multi-threaded application (in my
> case
> > it's a windows service executing multiple requests at the same time).
> But,
> > what are the pros and cons for re-using the searcher? What do you guys
> > usually do in your apps and why?
>
> It should be reused. Well, the underlying IndexReader is the thing that
> matters for reuse. Creating a searcher is pretty lightweight given a
> IndexReader. Opening an IndexReader can be fairly expensive.
>
> -Grant
--
Simone Chiaretta
Microsoft MVP ASP.NET - ASPInsider
Blog: http://codeclimber.net.nz
RSS: http://feeds2.feedburner.com/codeclimber
twitter: @simonech
Any sufficiently advanced technology is indistinguishable from magic
"Life is short, play hard"
Re: IndexSearcher - re-use or not re-use
Posted by Grant Ingersoll <gs...@apache.org>.
On Jan 13, 2010, at 5:08 PM, Artem Chereisky wrote:
> Hi,
>
> according to the documentation, IndexSearcher is thread and process safe so
> it's ok to use the same searcher in a multi-threaded application (in my case
> it's a windows service executing multiple requests at the same time). But,
> what are the pros and cons for re-using the searcher? What do you guys
> usually do in your apps and why?
It should be reused. Well, the underlying IndexReader is the thing that matters for reuse. Creating a searcher is pretty lightweight given a IndexReader. Opening an IndexReader can be fairly expensive.
-Grant