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 Daniel Cortes <dc...@fib.upc.edu> on 2005/06/30 13:41:23 UTC

A query in multipleFields

I have 2 indexs and the structure of the elements in this index are 
equals what in one index I have a field.Keyword "type" with value 
"forum" and  the other index with a value "blog".
How have I do to search in two indexs at same time?
How can I restrict the results with only "forum" or "blog" type?

For exeample:
* I want search dog blue in forums and blogs
* I want search dog blue only in forums


Thks and excuse me if this question is solved yet.

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


Re: A query in multipleFields

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jun 30, 2005, at 7:41 AM, Daniel Cortes wrote:
> I have 2 indexs and the structure of the elements in this index are  
> equals what in one index I have a field.Keyword "type" with value  
> "forum" and  the other index with a value "blog".
> How have I do to search in two indexs at same time?

Use MultiSearcher.  Instantiate IndexReader's for each index, and  
then construct a MultiSearcher using those two readers.  This is  
exactly how lucenebook.com works - one index for blog content, one  
for book content.

> How can I restrict the results with only "forum" or "blog" type?

Two options :

     1) Only use an IndexSearcher to the index you want to query if  
you are isolating it to only one type.
     2) Tack on a TermQuery for field "type" to the query (wrap the  
original query with BooleanQuery and add a required TermQuery clause  
for the type).

Personally I'd opt for #1 just to keep things simpler.

> For exeample:
> * I want search dog blue in forums and blogs

MultiSearcher across both indexes.

> * I want search dog blue only in forums

See above.

     Erik


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