open modify file with utf-8 encoding
[webpac2] / scripts / kinosearch.pl
1 #!/usr/bin/perl -w
2
3 # kinosearch.pl
4 #
5 # 11/04/07 15:41:02 CET Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use strict;
8
9 use KinoSearch::Simple;
10 use Data::Dump qw/dump/;
11
12 my ( $path, $query_string ) = @ARGV;
13
14 die "usage: $0 var/kinosearch/index 'query string'\n" unless $path && $query_string && -e $path;
15
16 my $index = KinoSearch::Simple->new(
17         path     => $path,
18         language => 'en',
19 );
20
21 my $total_hits = $index->search(
22         query      => $query_string,
23         offset     => 0,
24         num_wanted => 100,
25 );
26
27 print "Total hits: $total_hits\n";
28
29 while ( my $hit = $index->fetch_hit_hashref ) {
30         print dump( $hit );
31 }
32