On 1/27/13 10:39 PM, Marvin Humphrey wrote: > On Sat, Jan 26, 2013 at 5:12 AM, Aleksandar Radovanovic > <[email protected]> wrote: >> I was wondering can one search for a pattern of ordered keywords? For >> example, search for: >> >> bob book alice >> >> returns two different documents containing sentences: >> >> bob quickly gives the book to alice >> alice gently gives the book to olivia and bob >> >> If order matters, the correct match should be the first one only. Google for >> example, solves this problem with a phrase search: >> >> "bob * book * alice" >> >> Is it possible to implement something similar by using Lucy? > Maybe LucyX::Search::ProximityQuery with a high value for "within"? > > my $analyzer = $searcher->get_schema->fetch_analyzer("content"); > my $terms = $analyzer->split("bob book alice"); > my $proximity_query = LucyX::Search::ProximityQuery->new( > field => 'content', > terms => $terms, > within => 1000, # match within 1000 positions > ); > my $hits = $searcher->hits( query => $proximity_query ); > > Marvin Humphrey Thank you Marvin. It would be nice to have something like Google's phrase search: "here's looking * * kid"
Alex
