/[webpac2]/Webpacus2/lib/Webpacus/Action/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 /Webpacus2/lib/Webpacus/Action/Search.pm

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

revision 931 by dpavlin, Wed Oct 31 10:35:07 2007 UTC revision 934 by dpavlin, Wed Oct 31 11:26:39 2007 UTC
# Line 11  package Webpacus::Action::Search; Line 11  package Webpacus::Action::Search;
11  use base qw/Webpacus::Action Jifty::Action/;  use base qw/Webpacus::Action Jifty::Action/;
12    
13  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
14    use Webpacus::Webpac;
15    use KinoSearch::Simple;
16    
17  use Jifty::Param::Schema;  use Jifty::Param::Schema;
18  use Jifty::Action schema {  use Jifty::Action schema {
# Line 46  sub take_action { Line 48  sub take_action {
48          my $self = shift;          my $self = shift;
49    
50          my $search = Webpacus::Model::Search->load( $self->argument_value( 'field' ) );          my $search = Webpacus::Model::Search->load( $self->argument_value( 'field' ) );
51            my $query = $self->argument_value( 'query' );
52    
53          warn "## search = ",dump( $search );          warn "## search = ",dump( $search );
54    
55            my $index_path = Webpacus::Webpac->index_path;
56    
57            warn "## index_path = $index_path";
58    
59            my $index = KinoSearch::Simple->new(
60                    path => $index_path,
61                    language => 'en',
62            );
63    
64            my $total_hits = $index->search(
65                    query      => $query,
66                    offset     => 0,
67                    num_wanted => 100,
68            );
69    
70          my $message =          my $message =
71                  _('Results for') . " '" . $self->argument_value( 'query' ) . "' " .                  _('Found') . " $total_hits " .
72                    _('results for') . " '$query' " .
73                  _('on field') . ' ' . $search->name;                  _('on field') . ' ' . $search->name;
74    
75    
76            while ( my $hit = $index->fetch_hit_hashref ) {
77                    warn dump($hit);
78            }
79    
80    
81          $self->result->message( $message );          $self->result->message( $message );
82            
83          return 1;          return 1;

Legend:
Removed from v.931  
changed lines
  Added in v.934

  ViewVC Help
Powered by ViewVC 1.1.26