lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: [lucy-user] Ordered pattern match
Date Sun, 27 Jan 2013 19:39:56 GMT
On Sat, Jan 26, 2013 at 5:12 AM, Aleksandar Radovanovic
<Aleksandar@radovanovic.com> 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

Mime
View raw message