lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: PhraseQuery
Date Mon, 28 Jun 2004 22:52:58 GMT

On Jun 28, 2004, at 2:59 PM, Hetan Shah wrote:

> I was wondering if anyone out there had tried the PhraseQuery  class 
> and retrieved the results. I'm new to the whole search solution. I 
> have a need to do a exact phrase search. Any code sample would be 
> really appreciated.

     PhraseQuery query = new PhraseQuery();

     for (int i=0; i < words.length; i++) {
       query.add(new Term("field", phrase[i]));

That builds a PhraseQuery from a String[] of words and will be an exact 
match (unless you called setSlop with something greater than zero).


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message