Skip to content

Instantly share code, notes, and snippets.

@logie17
Created September 22, 2011 23:49
Show Gist options
  • Save logie17/1236380 to your computer and use it in GitHub Desktop.
Save logie17/1236380 to your computer and use it in GitHub Desktop.
An example of querying Lucy with Lucy::Simple
#! /usr/bin/env perl
use strict;
use warnings;
use Lucy::Simple;
my $index = Lucy::Simple->new(
path => './index',
language => 'en',
);
if ( my $query_string = $ARGV[0] ) {
my $total_hits = $index->search(
query => $query_string,
offset => 0,
num_wanted => 10,
);
print "Total hits: $total_hits\n";
while ( my $hit = $index->next ) {
print "$hit->{page}\n",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment