--- trunk/run.pl 2006/02/26 23:21:50 416 +++ 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; @@ -41,9 +40,9 @@ remove database and Hyper Estraier index before indexing -=item --one=database_name +=item --only=database_name -reindex just single database +reindex just single database (legacy name is --one) =item --config conf/config.yml @@ -59,13 +58,14 @@ my $clean = 0; my $config = 'conf/config.yml'; my $debug = 0; -my $one_db_name; +my $only_db_name; GetOptions( "limit=i" => \$limit, "offset=i" => \$offset, "clean" => \$clean, - "one=s" => \$one_db_name, + "one=s" => \$only_db_name, + "only=s" => \$only_db_name, "config" => \$config, "debug" => \$debug, ); @@ -76,25 +76,42 @@ 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(); while (my ($database, $db_config) = each %{ $config->{databases} }) { - next if ($one_db_name && $database !~ m/$one_db_name/i); + 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 @@ -198,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++; @@ -221,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}]"); + } } }