open index on each search
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 8 Dec 2010 21:32:32 +0000 (22:32 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 8 Dec 2010 21:32:32 +0000 (22:32 +0100)
this allows us to pick up changes in index generated by trigger

couchdb-external-kinosearch.pl

index d52f8f5..276ef19 100755 (executable)
@@ -12,10 +12,6 @@ use Data::Dump qw(dump);
 
 $|=1;
 
-my $searcher = KinoSearch::Search::IndexSearcher->new( 
-       index => '/tmp/index' 
-);
-
 our $json = Mojo::JSON->new;
 
 open(my $log, '>>', '/tmp/couchdb-external-kinosearch.log');
@@ -32,6 +28,10 @@ while(<STDIN>) {
 
        if ( my $q = $request->{query}->{q} ) {
 
+               my $searcher = KinoSearch::Search::IndexSearcher->new( 
+                       index => '/tmp/index' 
+               );
+
                my $hits = $searcher->hits( query => $q );
 
                $response->{json}->{total_hits} = $hits->total_hits;