--- trunk/run.pl 2006/03/22 00:18:56 423 +++ trunk/run.pl 2006/04/17 15:10:04 431 @@ -13,7 +13,6 @@ use WebPAC::Store 0.03; use WebPAC::Normalize::XML; use WebPAC::Output::TT; -use WebPAC::Output::Estraier '0.10'; use YAML qw/LoadFile/; use Getopt::Long; use File::Path; @@ -77,6 +76,11 @@ die "no databases in config file!\n" unless ($config->{databases}); +my $log = _new WebPAC::Common()->_get_logger(); + +my $use_indexer = $config->{use_indexer} || 'hyperestraier'; +$log->info("using $use_indexer indexing engine..."); + my $total_rows = 0; my $start_t = time(); @@ -84,18 +88,30 @@ next if ($only_db_name && $database !~ m/$only_db_name/i); - my $log = _new WebPAC::Common()->_get_logger(); + my $indexer; - # - # open Hyper Estraier database - # + my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration"); + $indexer_config->{database} = $database; + $indexer_config->{clean} = $clean; + $indexer_config->{label} = $db_config->{name}; + + if ($use_indexer eq 'hyperestraier') { + + # open Hyper Estraier database + use WebPAC::Output::Estraier '0.10'; + $indexer = new WebPAC::Output::Estraier( %{ $indexer_config } ); + + } elsif ($use_indexer eq 'kinosearch') { + + # open KinoSearch + use WebPAC::Output::KinoSearch; + $indexer = new WebPAC::Output::KinoSearch( %{ $indexer_config } ); - my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration"); - $est_config->{database} = $database; - $est_config->{clean} = $clean; - $est_config->{label} = $db_config->{name}; + } else { + $log->logdie("unknown use_indexer: $use_indexer"); + } - my $est = new WebPAC::Output::Estraier( %{ $est_config } ); + $log->logide("can't continue without valid indexer") unless ($indexer); # # now WebPAC::Store @@ -199,10 +215,10 @@ my $ds = $n->data_structure($row); - $est->add( + $indexer->add( id => $input->{name} . "/" . $mfn, ds => $ds, - type => $config->{hyperestraier}->{type}, + type => $config->{$use_indexer}->{type}, ); $total_rows++; @@ -222,12 +238,16 @@ # if (ref($db_config->{links}) eq 'ARRAY') { foreach my $link (@{ $db_config->{links} }) { - $log->info("adding link $database -> $link->{to} [$link->{credit}]"); - $est->add_link( - from => $database, - to => $link->{to}, - credit => $link->{credit}, - ); + if ($use_indexer eq 'hyperestraier') { + $log->info("adding link $database -> $link->{to} [$link->{credit}]"); + $indexer->add_link( + from => $database, + to => $link->{to}, + credit => $link->{credit}, + ); + } else { + $log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]"); + } } }