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 RanjithStar <ra...@gmail.com> on 2008/07/04 08:30:39 UTC

Multifield Search with OR and AND on different doc Fields

My requirement is to search on SEVEN Fields say F1,F2,F3,F4,F5,F6,F7 having
F1,F2,F3,F4 on one doc index
and F5,F6,F7 on a different doc index


I need to perform a search with ((F1=9 AND F2=4) AND (F3=keyword OR
F4=keyword)) OR (F5=9 AND F6=4 AND F7=keyword)

For normal search I was doing like this:
String[] sFields = { ID1, ID2, TITLE, CONTENT };
String[] sQuery = { id1, id2, sKeyword, sKeyword };
Occur[] flag = { BooleanClause.Occur.MUST, BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST, BooleanClause.Occur.MUST }; 
				
Query oQuery = oMultiParser.parse(sQuery, sFields, flag, oAnalyzer) ;
Hits hits = indexSearcher.search(oQuery);


How can I modify the above query in such a way that it has to search on
different doc Indexes?
-- 
View this message in context: http://www.nabble.com/Multifield-Search-with-OR-and-AND-on-different-doc-Fields-tp18273644p18273644.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: Multifield Search with OR and AND on different doc Fields

Posted by Karl Wettin <ka...@gmail.com>.
4 jul 2008 kl. 08.30 skrev RanjithStar:


>
> My requirement is to search on SEVEN Fields say F1,F2,F3,F4,F5,F6,F7  
> having
> F1,F2,F3,F4 on one doc index
> and F5,F6,F7 on a different doc index
>
>
> I need to perform a search with ((F1=9 AND F2=4) AND (F3=keyword OR
> F4=keyword)) OR (F5=9 AND F6=4 AND F7=keyword)
>
>
> For normal search I was doing like this:
> String[] sFields = { ID1, ID2, TITLE, CONTENT };
> String[] sQuery = { id1, id2, sKeyword, sKeyword };
> Occur[] flag = { BooleanClause.Occur.MUST, BooleanClause.Occur.MUST,
> BooleanClause.Occur.MUST, BooleanClause.Occur.MUST };
> 				
> Query oQuery = oMultiParser.parse(sQuery, sFields, flag, oAnalyzer) ;
> Hits hits = indexSearcher.search(oQuery);
>

Do you hav some sort of problem with executing the code above? What  
did you expect it to do and what was the results?


>
> How can I modify the above query in such a way that it has to search  
> on
> different doc Indexes?


I'm sorry, but I don't understand your question.

You want to know how to search in another directory than the one  
associated with your indexSearcher object?



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