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 John Wang <jo...@gmail.com> on 2007/12/01 20:48:38 UTC

multireader vs multisearcher

Hi:

   What is the difference between using:

1) MultiReader reader=....; // create multi reader from different indexes
    IndexSearcher searcher=new IndexSearcher(reader);
    searcher.search();

vs.

2) IndexSearcher searcher1=...
    IndexSearcher searcher 2=..

    MultiSearcher searcher=new MultiSearcher(new
IndexSearcher[]{searcher1,searcher});

    searcher.search();


I understand there are some differences with idf fixing etc., but seems to
me the api is presenting two ways of solving a problem with slightly
different results.

Thanks

-John

Re: multireader vs multisearcher

Posted by Doron Cohen <DO...@il.ibm.com>.
MultiReader is more efficient and is preferred when possible.
MultiSearcher allows further functionality.

Every time an index has more than a single segment (which is.
to say almost every index except for after calling optimize()),
Opening an IndexReader (or an IndexSearcher) above that index),
is actually using a MultiReader, each reader actually is a
SegmentReader. So MultiReader is a basic "tool" for
accessing a multi-segment index.

MultiSearcher is more geared for situations where an
application maintains several separate indexes, and needs
to allow searching all (or some) of them. They may reside in
separate machines. The specific Searcher implementation
to access some of them may be Web based. Still, MultiSearcher),
allows to search all of them with a single search() call.

"John Wang" <jo...@gmail.com> wrote on 01/12/2007 21:48:38:

> Hi:
>
>    What is the difference between using:
>
> 1) MultiReader reader=....; // create multi reader from different indexes
>     IndexSearcher searcher=new IndexSearcher(reader);
>     searcher.search();
>
> vs.
>
> 2) IndexSearcher searcher1=...
>     IndexSearcher searcher 2=..
>
>     MultiSearcher searcher=new MultiSearcher(new
> IndexSearcher[]{searcher1,searcher});
>
>     searcher.search();
>
>
> I understand there are some differences with idf fixing etc.,
> but seems to
> me the api is presenting two ways of solving a problem with slightly
> different results.
>
> Thanks
>
> -John


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