/[Grep]/lib/Grep/Search.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Search.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 53 by dpavlin, Wed Feb 21 16:06:25 2007 UTC revision 60 by dpavlin, Wed Feb 21 19:31:26 2007 UTC
# Line 12  my $index_path = Jifty::Util->app_root . Line 12  my $index_path = Jifty::Util->app_root .
12  my ( $analyzer, $store, $writer );  my ( $analyzer, $store, $writer );
13    
14  my $debug = 1;  my $debug = 1;
15    my $create;
16    
17  sub create {  sub create {
18    
19          my $create = 0;          if (defined( $create )) {
20                    Jifty->log->debug("using previous create $create");
21                    return $create;
22            }
23    
24          if (! -e "$index_path/segments") {          if (! -e "$index_path/segments") {
25                  $create = 1;                  $create = 1;
26                  Jifty->log->debug("create index $index_path") unless ($store);                  Jifty->log->debug("create index $index_path");
27          } else {          } else {
28                  Jifty->log->debug("open index: $index_path") unless ($store);                  $create = 0;
29                    Jifty->log->debug("open index: $index_path");
30          }          }
31          return $create;          return $create;
32  }  }
# Line 120  sub collection { Line 126  sub collection {
126    
127          my $q = shift or die "no q?";          my $q = shift or die "no q?";
128    
129            return if ( $self->create );
130    
131          my $searcher = new Lucene::Search::IndexSearcher($self->store);          my $searcher = new Lucene::Search::IndexSearcher($self->store);
132          my $parser = new Lucene::QueryParser("content", $self->analyzer);          my $parser = new Lucene::QueryParser("content", $self->analyzer);
133          my $query = $parser->parse( $q );          my $query = $parser->parse( $q );
134    
135          Jifty->log->debug("searching for '$q'");          Jifty->log->debug("searching for '$q' using ", $query->toString);
136    
137          my $hits = $searcher->search($query);          my $hits = $searcher->search($query);
138          my $num_hits = $hits->length();          my $num_hits = $hits->length();
# Line 177  sub finish { Line 185  sub finish {
185                  $writer->close;                  $writer->close;
186          }          }
187          undef $writer;          undef $writer;
188            undef $create;
189    
190            return;
191  }  }
192    
193    =for TODO
194    
195  sub _signal {  sub _signal {
196          my $s = shift;          my $s = shift;
197          warn "catched SIG $s\n";          warn "catched SIG $s\n";
# Line 190  $SIG{'__DIE__'} = \&_signal; Line 203  $SIG{'__DIE__'} = \&_signal;
203  $SIG{'INT'} = \&_signal;  $SIG{'INT'} = \&_signal;
204  $SIG{'QUIT'} = \&_signal;  $SIG{'QUIT'} = \&_signal;
205    
206    =cut
207    
208  =head2 snippet  =head2 snippet
209    

Legend:
Removed from v.53  
changed lines
  Added in v.60

  ViewVC Help
Powered by ViewVC 1.1.26