use WebPAC::Output::EstraierNative;
$indexer = new WebPAC::Output::EstraierNative( %{ $indexer_config } );
- $use_indexer = 'hyperestraier';
-
} elsif ($use_indexer eq 'kinosearch') {
# open KinoSearch
%{ $input },
);
+ my $report_fh;
+ if ($stats || $validate) {
+ my $path = "out/report/" . $database . '-' . $input->{name} . '.txt';
+ open($report_fh, '>', $path) || $log->logdie("can't open $path: $!");
+
+ print $report_fh "Report for database '$database' input '$input->{name}' records ",
+ $offset || 1, "-", $limit || $input->{limit} || $maxmfn, "\n\n";
+ $log->info("Generating report file $path");
+ }
+
my @norm_array = ref($input->{normalize}) eq 'ARRAY' ?
@{ $input->{normalize} } : ( $input->{normalize} );
# reset position in database
$input_db->seek(1);
+ # generate name of config key for indexer (strip everything after -)
+ my $indexer_config = $use_indexer;
+ $indexer_config =~ s/^(\w+)-?.*$/$1/g;
+
foreach my $pos ( 0 ... $input_db->size ) {
my $row = $input_db->fetch || next;
if ($validate) {
if ( my $errors = $validate->validate_errors( $row, $input_db->dump ) ) {
$log->error( "MFN $mfn validation error:\n",
- dump( $errors )
+ $validate->report_error( $errors )
);
}
}
$indexer->add(
id => $input->{name} . "/" . $mfn,
ds => $ds,
- type => $config->{$use_indexer}->{type},
+ type => $config->{$indexer_config}->{type},
) if ($indexer && $ds);
if ($marc) {
$total_rows++;
}
- $log->info("validation errors:\n", dump( $validate->all_errors ) ) if ($validate && defined($validate->all_errors));
+ if ($validate) {
+ my $errors = $validate->report;
+ if ($errors) {
+ $log->info("validation errors:\n$errors\n" );
+ print $report_fh "$errors\n" if ($report_fh);
+ }
+ }
- $log->info("statistics of fields usage:\n", $input_db->stats) if ($stats);
+ if ($stats) {
+ my $s = $input_db->stats;
+ $log->info("statistics of fields usage:\n$s");
+ print $report_fh "Statistics of fields usage:\n$s" if ($report_fh);
+ }
# close MARC file
$marc->finish if ($marc);
+ # close report
+ close($report_fh) if ($report_fh)
}
}