Wrap the PhraseQuery's inside a BooleanQuery to achieve AND/OR.

        Erik


On Apr 18, 2006, at 10:00 PM, Vishal Bathija wrote:

Hi,
I am trying to find the number of hits for a phrase using the
PhraseQuery. I would like to know how I could seach for 2 phrases at
the same time using the boolean operators OR, AND. The code snippet
that I use to seach for one phrase is

String test ="avoids deadlock"
String[] phraseTerms = test.split( " ");
PhraseQuery query =new PhraseQuery();                   
searcher = new IndexSearcher(rd);                       
Term[] phrTerm=new Term[phraseTerms.length];
for(int u=0; u<phraseTerms.length;u++)
{
phrTerm[u]=new Term("contents",phraseTerms[u]);
query.add(phrTerm[u]);
}

Hits hits = searcher.search(query);     

How can I extend this to search for multiple phrases?

Regards
Vishal
--
Vishal Bathija
Graduate Student
Department of Computer Science & Systems Analysis
Miami University
Oxford,Ohio
Phone: (513)-461-9239

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to