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 Toby Tremayne <To...@lonelyplanet.com.au> on 2004/07/02 00:38:15 UTC

search multiple indexes

Possibly a silly question - but how would I go about searching multiple
indexes using lucene?  Do I need to basically repeat the code I use to
search one index for each one, or is there a better way to do it?

 

Toby

 

-------------------------------------------------------------------

 

     Life is poetry - write it in your own words

 

-------------------------------------------------------------------

 

Toby Tremayne

Code Poet and Zen Master of the Heavy Sleep

Lonely Planet Publications

+61 416 048 090

ICQ: 13107913

 



______________________________________________________________________
This email, including attachments, is intended only for the addressee
and may be confidential, privileged and subject to copyright.  If you
have received this email in error, please advise the sender and delete
it.  If you are not the intended recipient of this email, you must not
use, copy or disclose its content to anyone.  You must not copy or 
communicate to others content that is confidential or subject to 
copyright, unless you have the consent of the content owner.

Re: search multiple indexes

Posted by David Spencer <da...@tropo.com>.
Stefan Groschupf wrote:
>> http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/ 
>> MultiSearcher.html
>>
> 100% Right.
> I personal found code samples more interesting then just java doc.

Good point.

> That why my hint, here the code snippet from nutch:

But - warning - in normal use of Lucene you don't need the Similarity 
stuff..
> 
> /** Construct given a number of indexed segments. */
>   public IndexSearcher(File[] segmentDirs) throws IOException {
>     NutchSimilarity sim = new NutchSimilarity();
>     Searchable[] searchables = new Searchable[segmentDirs.length];
>     segmentNames = new String[segmentDirs.length];
>     for (int i = 0; i < segmentDirs.length; i++) {
>       org.apache.lucene.search.Searcher searcher =
>         new org.apache.lucene.search.IndexSearcher
>         (new File(segmentDirs[i], "index").toString());
>       searcher.setSimilarity(sim);
>       searchables[i] = searcher;
>       segmentNames[i] = segmentDirs[i].getName();
>     }
>     this.luceneSearcher = new MultiSearcher(searchables);
>     this.luceneSearcher.setSimilarity(sim);
>   }
> 
> Kent Beck said: "Monkey see, Monkey do." ;-)
> 
> Cheers,
> Stefan
> 
> ---------------------------------------------------------------
> enterprise information technology consulting
> open technology:   http://www.media-style.com
> open source:           http://www.weta-group.net
> open discussion:    http://www.text-mining.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 


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


Re: search multiple indexes

Posted by Stefan Groschupf <sg...@media-style.com>.
> http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/ 
> MultiSearcher.html
>
100% Right.
I personal found code samples more interesting then just java doc.
That why my hint, here the code snippet from nutch:

/** Construct given a number of indexed segments. */
   public IndexSearcher(File[] segmentDirs) throws IOException {
     NutchSimilarity sim = new NutchSimilarity();
     Searchable[] searchables = new Searchable[segmentDirs.length];
     segmentNames = new String[segmentDirs.length];
     for (int i = 0; i < segmentDirs.length; i++) {
       org.apache.lucene.search.Searcher searcher =
         new org.apache.lucene.search.IndexSearcher
         (new File(segmentDirs[i], "index").toString());
       searcher.setSimilarity(sim);
       searchables[i] = searcher;
       segmentNames[i] = segmentDirs[i].getName();
     }
     this.luceneSearcher = new MultiSearcher(searchables);
     this.luceneSearcher.setSimilarity(sim);
   }

Kent Beck said: "Monkey see, Monkey do." ;-)

Cheers,
Stefan

---------------------------------------------------------------
enterprise information technology consulting
open technology:   http://www.media-style.com
open source:           http://www.weta-group.net
open discussion:    http://www.text-mining.org


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


Re: search multiple indexes

Posted by David Spencer <da...@tropo.com>.
Stefan Groschupf wrote:

>> Possibly a silly question - but how would I go about searching multiple
>> indexes using lucene?  Do I need to basically repeat the code I use to
>> search one index for each one, or is there a better way to do it?
> 
> 
> Take a look to the nutch.org sourcecode. It does what you are searching 

Isn't the answer closer to home?

http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/MultiSearcher.html

> for.
> HTH
> Stefan
> ---------------------------------------------------------------
> enterprise information technology consulting
> open technology:   http://www.media-style.com
> open source:           http://www.weta-group.net
> open discussion:    http://www.text-mining.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 


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


Re: search multiple indexes

Posted by Stefan Groschupf <sg...@media-style.com>.
> Possibly a silly question - but how would I go about searching multiple
> indexes using lucene?  Do I need to basically repeat the code I use to
> search one index for each one, or is there a better way to do it?

Take a look to the nutch.org sourcecode. It does what you are searching 
for.
HTH
Stefan
---------------------------------------------------------------
enterprise information technology consulting
open technology:   http://www.media-style.com
open source:           http://www.weta-group.net
open discussion:    http://www.text-mining.org


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