/[webpac2]/trunk/lib/WebPAC/Output/KinoSearch.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 /trunk/lib/WebPAC/Output/KinoSearch.pm

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

revision 919 by dpavlin, Tue Oct 30 22:07:11 2007 UTC revision 986 by dpavlin, Sun Nov 4 11:55:45 2007 UTC
# Line 7  use base qw/WebPAC::Common WebPAC::Outpu Line 7  use base qw/WebPAC::Common WebPAC::Outpu
7  __PACKAGE__->mk_accessors(qw(  __PACKAGE__->mk_accessors(qw(
8          path          path
9          database          database
10            input
11          encoding          encoding
12          clean          clean
13    
# Line 15  __PACKAGE__->mk_accessors(qw( Line 16  __PACKAGE__->mk_accessors(qw(
16    
17  use KinoSearch::Simple;  use KinoSearch::Simple;
18  use File::Path;  use File::Path;
19  use Encode qw/from_to/;  use Encode qw/decode/;
20  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
21  use Storable;  use Storable;
22    
# Line 90  sub init { Line 91  sub init {
91    
92          $self->encoding( 'ISO-8859-2' ) unless $self->encoding;          $self->encoding( 'ISO-8859-2' ) unless $self->encoding;
93    
94            ## FIXME we shouldn't re-create whole KinoSearch index every time!
95            $self->clean( 1 );
96    
97          if ( ! -e $self->path ) {          if ( ! -e $self->path ) {
98                  mkpath $self->path || $log->logdie("can't create ", $self->path,": $!");                  mkpath $self->path || $log->logdie("can't create ", $self->path,": $!");
99                  $log->info("created ", $self->path);                  $log->info("created ", $self->path);
# Line 132  sub add { Line 136  sub add {
136          $log->logdie("need id") unless defined $id;          $log->logdie("need id") unless defined $id;
137          $log->logdie("need ds") unless $ds;          $log->logdie("need ds") unless $ds;
138    
         $log->debug("id: $id ds = ",dump($ds));  
   
139          my $hash = $self->ds_to_hash( $ds, 'search' ) || return;          my $hash = $self->ds_to_hash( $ds, 'search' ) || return;
140    
141            $hash->{id}       ||= $id;
142          $hash->{database} ||= $self->database;          $hash->{database} ||= $self->database;
143          $hash->{id} ||= $id;          $hash->{input}    ||= $self->input;
144    
145            foreach my $f ( keys %$hash ) {
146                    if ( ref($hash->{$f}) eq 'ARRAY' ) {
147                            $hash->{$f} = join(' <*> ', @{ $hash->{$f} });
148                    }
149    #               $hash->{$f} = decode( $self->encoding, $hash->{$f} );
150            }
151    
152          $log->debug("add( $id, ", sub { dump($ds) }," ) => ", sub { dump( $hash ) });          $log->debug("add( $id, ", sub { dump($ds) }," ) => ", sub { dump( $hash ) });
153    
154          $self->index->add_doc( $hash );          $self->index->add_doc( $hash );
155    
156            $self->{count}++;
157    
158          return 1;          return 1;
159  }  }
160    
# Line 159  sub finish { Line 171  sub finish {
171    
172          my $log = $self->_get_logger();          my $log = $self->_get_logger();
173    
174          $log->info("dummy finish");          $log->info("indexed ", $self->{count}, " records");
175    
176  }  }
177    

Legend:
Removed from v.919  
changed lines
  Added in v.986

  ViewVC Help
Powered by ViewVC 1.1.26