Add a "slop" factor to your phrase query.
In the string passed to QueryParser append "~2" (or some larger integer). This 
allows the words to be recognized regardless of their order within the phrase.

Alternatively, construct your query programmatically using SpanQuery(), similar 
to PhraseQuery() but supposedly better at handling the out-of-order situation.


-- Neal

-----Original Message-----
From: Trevor Watson [mailto:[email protected]]
Sent: Monday, August 17, 2009 3:37 PM
To: [email protected]
Subject: Phrase starts with queries

Hopefully this is the correct place to post this, new to the community
and attempting to learn Lucene on top of all other tasks.
Unfortunately, my manager thinks this is easy since the he thinks it
is.  Not necessarily the case but hopefully you will just say "click
here" :)


I am attempting to create a phrase "starts with" and "ends with" instead
of a Term starts with and ends with.

So if we have
Sam Adams
Steve Adams
Adams, Sam
Adams, Samuel

We can do a "Starts with" Sam and get "Sam Adams", but not "Adams, Sam"
or "Adams, Samuel".  Any attempts I've done have given me all of them
(since Sam starts a Term).

Thanks in advance.

Trevor Watson

Reply via email to