r1529@llin: dpavlin | 2007-11-04 15:44:22 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 4 Nov 2007 14:44:26 +0000 (14:44 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 4 Nov 2007 14:44:26 +0000 (14:44 +0000)
 Simpliest possible searcher helper for KinoSearch to see index content

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@995 07558da8-63fa-0310-ba24-9fe276d99e06

scripts/kinosearch.pl [new file with mode: 0755]

diff --git a/scripts/kinosearch.pl b/scripts/kinosearch.pl
new file mode 100755 (executable)
index 0000000..a75ca0c
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+
+# kinosearch.pl
+#
+# 11/04/07 15:41:02 CET Dobrica Pavlinusic <dpavlin@rot13.org>
+
+use strict;
+
+use KinoSearch::Simple;
+use Data::Dump qw/dump/;
+
+my ( $path, $query_string ) = @ARGV;
+
+die "usage: $0 var/kinosearch/index 'query string'\n" unless $path && $query_string && -e $path;
+
+my $index = KinoSearch::Simple->new(
+       path     => $path,
+       language => 'en',
+);
+
+my $total_hits = $index->search(
+       query      => $query_string,
+       offset     => 0,
+       num_wanted => 100,
+);
+
+print "Total hits: $total_hits\n";
+
+while ( my $hit = $index->fetch_hit_hashref ) {
+       print dump( $hit );
+}
+