I am not sure if I understand you. Do I add the terms for the second phrase immediately after I add the terms for the first phrase. When do i wrap the PhraseQuery I construct into a BooleanQuery.
For instance String newTerm1= "avoids deadlock"; String newTerm2= "reduces cost"; PhraseQuery query =new PhraseQuery(); String[] phraseTerms1 = newTerm1.split( " "); Term[] phrTerm1=new Term[phraseTerms1.length]; for(int u=0; u<phraseTerms1.length;u++) { phrTerm1[u]=new Term("contents",phraseTerms1[u]); query.add(phrTerm1[u]); } String[] phraseTerms2 = newTerm2.split( " "); Term[] phrTerm2=new Term[phraseTerms2.length]; for(int u=0; u<phraseTerms2.length;u++) { phrTerm2[u]=new Term("contents",phraseTerms2[u]); query.add(phrTerm2[u]); } Hits hits = searcher.search(query); The code above just adds the terms of phrase2 following the terms for phrase1. Can you give me an example building a BooleanQuery OR for the newTerm1 and newTerm2. Thanks again Vishal On 4/18/06, Erik Hatcher <[EMAIL PROTECTED]> wrote: > 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] > > -- 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]