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 Cheng <zh...@gmail.com> on 2011/06/23 16:18:51 UTC
Search multiple directories simultaneously
Hi,
I have multiple indexed folders (or directories), each holding indexing
files for specific purposes. I want to do a search over these folders (or
directories) in a same query.
Is it possible?
Thanks
Re: Search multiple directories simultaneously
Posted by Cheng <zh...@gmail.com>.
thanks man. very condense and easy to follow.
can i ask how the multiple search will impact the performance? i have
probably 50GB data in each of the 10-20 folders.
On Fri, Jun 24, 2011 at 1:04 AM, Uwe Schindler <uw...@thetaphi.de> wrote:
> IndexReader index1 = IndexReader.open(dir1);
> IndexReader index2 = IndexReader.open(dir2);
> IndexReader index3 = IndexReader.open(dir3);
> ...
> IndexReader all = new MultiReader(index1, index2, index3,...);
> IndexSearcher searcher = new IndexSearcher(all);
>
> ...search your indexes...
>
> all.close();
> index1.close();
> index2.close();
> index3.close();
> ...
>
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: Cheng [mailto:zhoucheng2008@gmail.com]
> > Sent: Thursday, June 23, 2011 4:19 PM
> > To: java-user@lucene.apache.org
> > Subject: Search multiple directories simultaneously
> >
> > Hi,
> >
> > I have multiple indexed folders (or directories), each holding indexing
> files
> > for specific purposes. I want to do a search over these folders (or
> > directories) in a same query.
> >
> > Is it possible?
> >
> > Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
RE: Search multiple directories simultaneously
Posted by Uwe Schindler <uw...@thetaphi.de>.
IndexReader index1 = IndexReader.open(dir1);
IndexReader index2 = IndexReader.open(dir2);
IndexReader index3 = IndexReader.open(dir3);
...
IndexReader all = new MultiReader(index1, index2, index3,...);
IndexSearcher searcher = new IndexSearcher(all);
...search your indexes...
all.close();
index1.close();
index2.close();
index3.close();
...
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: Cheng [mailto:zhoucheng2008@gmail.com]
> Sent: Thursday, June 23, 2011 4:19 PM
> To: java-user@lucene.apache.org
> Subject: Search multiple directories simultaneously
>
> Hi,
>
> I have multiple indexed folders (or directories), each holding indexing
files
> for specific purposes. I want to do a search over these folders (or
> directories) in a same query.
>
> Is it possible?
>
> Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org