> Lucene has a syntax "foo bar"~10 for finding foo within 10 words
of bar.
sure .. take a look at this (take from the API):
--snip--
query = SpanNearQuery.new(:slop => 2)
query << SpanTermQuery.new(:field, "quick")
query << SpanTermQuery.new(:field, "brown")
query << SpanTermQuery.new(:field, "fox")
# matches => "quick brown speckled sleepy fox"
|______2______^
# matches => "quick brown speckled fox"
|__1__^
# matches => "brown quick _____ fox"
^_____2_____|
A SpanNearQuery is like a combination between a PhraseQuery and a
BooleanQuery. It matches sub-SpanQueries which are added as clauses but
those clauses must occur within a slop edit distance of eachother.
http://ferret.davebalmain.com/api/classes/Ferret/Search/Spans/SpanNearQuery.html
--snip--
and even better, you can force the order of the words.. the above example
doesn''t care about the order of the words, but if the order is
important
to you, you can build queries that will search for terms in order and a
maximal distance between the words..
look at http://blog.omdb-beta.org/2007/1/16/brad_pitt
Ben