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 Raul Raja Martinez <do...@estudiowebs.com> on 2006/03/03 16:00:05 UTC

Search on many indexes at once

Is it possible to search many indexes in one query and get back the Hits 
ordered by relevance?

Can someone point me out to some document or place that explains this?

any help is appreciated.

Thanks.

Raul.


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


Re: Search on many indexes at once

Posted by Chris Hostetter <ho...@fucit.org>.
: Is it possible to search many indexes in one query and get back the Hits
: ordered by relevance?
:
: Can someone point me out to some document or place that explains this?

I've never used it, but the javadocs for MultiSearcher seem pretty
straight forward.



-Hoss


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


Re: Search on many indexes at once

Posted by Raul Raja Martinez <do...@estudiowebs.com>.
Thanks Chris I'll provably try passing the MultiSearcher instance as a 
parameter so that I can use subDoc and so.
It makes sense though to have a getIndex() method inside hit or document
that returns some information about where that hit or document belongs 
to. Do you think that is reasonable to file a JIRA petition for this, 
I'm new to Lucene and I don't know what are the policies around these 
matters.


Chris Hostetter wrote:
> : It looks like I don't have access to the searcher.subSearcher or subDoc,
> : since I get just a Hits object. Is it possible to know the Index folder
> : based on a hit?
> 
> As i understand it (like i said: i've never used these methods) the doc id
> returned by Hits.id() is what you pass to subSearcher to find out which
> index it came from.
> 
> : I'm on a SearchResults component that takes a Hits object as parameter
> : and the search is actually performed by other component.
> 
> It sounds like the API you are working with abstracts away the
> MultiSearcher so you don't have access to it once you get the Hits object.
> I think that makes it just about impossible to get the info you want.
> 
> I guess you either need to add a "doctype" field to all of the indexes, or
> deduce the doctype based on what fields are in each doc, or change the API
> you are using to give you access to the info you need.
> 
> 
> -Hoss


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


Re: Search on many indexes at once

Posted by Chris Hostetter <ho...@fucit.org>.
: It looks like I don't have access to the searcher.subSearcher or subDoc,
: since I get just a Hits object. Is it possible to know the Index folder
: based on a hit?

As i understand it (like i said: i've never used these methods) the doc id
returned by Hits.id() is what you pass to subSearcher to find out which
index it came from.

: I'm on a SearchResults component that takes a Hits object as parameter
: and the search is actually performed by other component.

It sounds like the API you are working with abstracts away the
MultiSearcher so you don't have access to it once you get the Hits object.
I think that makes it just about impossible to get the info you want.

I guess you either need to add a "doctype" field to all of the indexes, or
deduce the doctype based on what fields are in each doc, or change the API
you are using to give you access to the info you need.


-Hoss


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


Re: Search on many indexes at once

Posted by Raul Raja Martinez <do...@estudiowebs.com>.
Hi Chris, thanks for the quick response,

It looks like I don't have access to the searcher.subSearcher or subDoc, 
since I get just a Hits object. Is it possible to know the Index folder 
based on a hit?

I'm on a SearchResults component that takes a Hits object as parameter 
and the search is actually performed by other component.

This is the method that performs the search:

public Hits searchMultipleIndexes(String query, IndexSearcher...searchers) {

  MultiSearcher searcher = new MultiSearcher(searchers);

  Query q = QueryParser.parse(query, "title", new StandardAnalyzer());

  return searcher.search(q);

}

and later a iterate over the hits and I need to know if they belong to 
Categories, News etc... which all are different indexes.

any help appreciated.

thanks.

Raul

Chris Hostetter wrote:
> : got this working, I just need to know how to get from a resulting hit
> : which index the hit belongs to. I have News, Channels, Categories and
> : Images as different Indexes and I need to link to one page or another
> : based on whether a hit belong to an index or not.
> 
> take a look at subSearcher and subDoc.
> 
> 
> -Hoss


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


Re: Search on many indexes at once

Posted by Chris Hostetter <ho...@fucit.org>.
: got this working, I just need to know how to get from a resulting hit
: which index the hit belongs to. I have News, Channels, Categories and
: Images as different Indexes and I need to link to one page or another
: based on whether a hit belong to an index or not.

take a look at subSearcher and subDoc.


-Hoss


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


Re: Search on many indexes at once

Posted by Raul Raja Martinez <do...@estudiowebs.com>.
Thanks I found some info in Lucene in action about Multisearcher and I 
got this working, I just need to know how to get from a resulting hit 
which index the hit belongs to. I have News, Channels, Categories and 
Images as different Indexes and I need to link to one page or another 
based on whether a hit belong to an index or not.

Any ideas?

Jeff Rodenburg wrote:
> Raul -
> 
> You'll want to look at the MultiSearcher and ParallelMultiSearcher classes
> for this.
> 
> On 3/3/06, Raul Raja Martinez <do...@estudiowebs.com> wrote:
>> Is it possible to search many indexes in one query and get back the Hits
>> ordered by relevance?
>>
>> Can someone point me out to some document or place that explains this?
>>
>> any help is appreciated.
>>
>> Thanks.
>>
>> Raul.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
> 


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


Re: Search on many indexes at once

Posted by Jeff Rodenburg <je...@gmail.com>.
Raul -

You'll want to look at the MultiSearcher and ParallelMultiSearcher classes
for this.

On 3/3/06, Raul Raja Martinez <do...@estudiowebs.com> wrote:
>
> Is it possible to search many indexes in one query and get back the Hits
> ordered by relevance?
>
> Can someone point me out to some document or place that explains this?
>
> any help is appreciated.
>
> Thanks.
>
> Raul.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>