/[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 535 by dpavlin, Sun Apr 30 19:06:09 2006 UTC revision 536 by dpavlin, Mon Jun 26 16:39:51 2006 UTC
# Line 9  use KinoSearch::InvIndexer; Line 9  use KinoSearch::InvIndexer;
9  use KinoSearch::Analysis::PolyAnalyzer;  use KinoSearch::Analysis::PolyAnalyzer;
10  use Encode qw/from_to/;  use Encode qw/from_to/;
11  use Data::Dumper;  use Data::Dumper;
12    use Storable;
13    
14  =head1 NAME  =head1 NAME
15    
# Line 16  WebPAC::Output::KinoSearch - Create Kino Line 17  WebPAC::Output::KinoSearch - Create Kino
17    
18  =head1 VERSION  =head1 VERSION
19    
20  Version 0.01  Version 0.02
21    
22  =cut  =cut
23    
24  our $VERSION = '0.01';  our $VERSION = '0.02';
25    
26  =head1 SYNOPSIS  =head1 SYNOPSIS
27    
# Line 99  sub new { Line 100  sub new {
100                  analyzer => $analyzer,                  analyzer => $analyzer,
101          );          );
102    
103            my $fields_path = $self->{index_path} . '/fields.storable';
104            $fields_path =~ s#//#/#g;
105            if (-e $fields_path) {
106                    $self->{fields} = retrieve($fields_path) ||
107                            $log->warn("can't open $fields_path: $!");
108            } else {
109                    $log->error("This will be dummy run since no fields statistics are found!");
110                    $log->error("You will have to re-run indexing to get search results!");
111                    $self->{dummy_run} = 1;
112            }
113            $self->{fields_path} = $fields_path;
114    
115          foreach my $f (@{ $self->{fields} }) {          foreach my $f (@{ $self->{fields} }) {
116                  $self->{invindex}->spec_field(                  $self->{invindex}->spec_field(
117                          name  => $f,                          name  => $f,
# Line 158  sub add { Line 171  sub add {
171          sub add_value($$$$$) {          sub add_value($$$$$) {
172                  my ($self,$log,$doc,$n,$v) = @_;                  my ($self,$log,$doc,$n,$v) = @_;
173                  return unless ($v);                  return unless ($v);
174    
175                    $self->{value_usage}->{$n}++;
176                    return if ($self->{dummy_run});
177    
178                  eval { $doc->set_value($n, $self->convert($v) ) };                  eval { $doc->set_value($n, $self->convert($v) ) };
179                  $log->warn("can't insert: $n = $v") if ($@);                  $log->warn("can't insert: $n = $v") if ($@);
180          }          }
# Line 208  Close index Line 225  Close index
225  sub finish {  sub finish {
226          my $self = shift;          my $self = shift;
227    
228          $self->_get_logger()->info("finish index writing to disk");          my $log = $self->_get_logger();
229    
230            $log->info("finish index writing to disk");
231          $self->{invindex}->finish;          $self->{invindex}->finish;
232    
233            $log->info("writing value usage file");
234    
235            # add fields from last run
236            map { $self->{value_usage}->{$_}++ } @{ $self->{fields} };
237    
238            my @fields = keys %{ $self->{value_usage} };
239            store \@fields, $self->{fields_path} ||
240                    $log->warn("can't write $self->{fields_path}: $!");
241    
242  }  }
243    
244  =head2 convert  =head2 convert

Legend:
Removed from v.535  
changed lines
  Added in v.536

  ViewVC Help
Powered by ViewVC 1.1.26