lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: using boolean operators with the PhraseQuery
Date Wed, 19 Apr 2006 02:58:14 GMT
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: 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


Mime
View raw message