13 |
use WebPAC::Store 0.03; |
use WebPAC::Store 0.03; |
14 |
use WebPAC::Normalize::XML; |
use WebPAC::Normalize::XML; |
15 |
use WebPAC::Output::TT; |
use WebPAC::Output::TT; |
|
use WebPAC::Output::Estraier '0.10'; |
|
16 |
use YAML qw/LoadFile/; |
use YAML qw/LoadFile/; |
17 |
use Getopt::Long; |
use Getopt::Long; |
18 |
use File::Path; |
use File::Path; |
76 |
|
|
77 |
die "no databases in config file!\n" unless ($config->{databases}); |
die "no databases in config file!\n" unless ($config->{databases}); |
78 |
|
|
79 |
|
my $log = _new WebPAC::Common()->_get_logger(); |
80 |
|
|
81 |
|
my $use_indexer = $config->{use_indexer} || 'hyperestraier'; |
82 |
|
$log->info("using $use_indexer indexing engine..."); |
83 |
|
|
84 |
my $total_rows = 0; |
my $total_rows = 0; |
85 |
my $start_t = time(); |
my $start_t = time(); |
86 |
|
|
88 |
|
|
89 |
next if ($only_db_name && $database !~ m/$only_db_name/i); |
next if ($only_db_name && $database !~ m/$only_db_name/i); |
90 |
|
|
91 |
my $log = _new WebPAC::Common()->_get_logger(); |
my $indexer; |
92 |
|
|
93 |
# |
my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration"); |
94 |
# open Hyper Estraier database |
$indexer_config->{database} = $database; |
95 |
# |
$indexer_config->{clean} = $clean; |
96 |
|
$indexer_config->{label} = $db_config->{name}; |
97 |
|
|
98 |
|
# important: clean database just once! |
99 |
|
$clean = 0; |
100 |
|
|
101 |
|
if ($use_indexer eq 'hyperestraier') { |
102 |
|
|
103 |
|
# open Hyper Estraier database |
104 |
|
use WebPAC::Output::Estraier '0.10'; |
105 |
|
$indexer = new WebPAC::Output::Estraier( %{ $indexer_config } ); |
106 |
|
|
107 |
|
} elsif ($use_indexer eq 'kinosearch') { |
108 |
|
|
109 |
|
# open KinoSearch |
110 |
|
use WebPAC::Output::KinoSearch; |
111 |
|
$indexer_config->{clean} = 1 unless (-e $indexer_config->{index_path}); |
112 |
|
$indexer = new WebPAC::Output::KinoSearch( %{ $indexer_config } ); |
113 |
|
|
114 |
my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration"); |
} else { |
115 |
$est_config->{database} = $database; |
$log->logdie("unknown use_indexer: $use_indexer"); |
116 |
$est_config->{clean} = $clean; |
} |
|
$est_config->{label} = $db_config->{name}; |
|
117 |
|
|
118 |
my $est = new WebPAC::Output::Estraier( %{ $est_config } ); |
$log->logide("can't continue without valid indexer") unless ($indexer); |
119 |
|
|
120 |
# |
# |
121 |
# now WebPAC::Store |
# now WebPAC::Store |
219 |
|
|
220 |
my $ds = $n->data_structure($row); |
my $ds = $n->data_structure($row); |
221 |
|
|
222 |
$est->add( |
$indexer->add( |
223 |
id => $input->{name} . "/" . $mfn, |
id => $input->{name} . "/" . $mfn, |
224 |
ds => $ds, |
ds => $ds, |
225 |
type => $config->{hyperestraier}->{type}, |
type => $config->{$use_indexer}->{type}, |
226 |
); |
); |
227 |
|
|
228 |
$total_rows++; |
$total_rows++; |
230 |
|
|
231 |
}; |
}; |
232 |
|
|
233 |
|
eval { $indexer->finish } if ($indexer->can('finish')); |
234 |
|
|
235 |
my $dt = time() - $start_t; |
my $dt = time() - $start_t; |
236 |
$log->info("$total_rows records indexed in " . |
$log->info("$total_rows records indexed in " . |
237 |
sprintf("%.2f sec [%.2f rec/sec]", |
sprintf("%.2f sec [%.2f rec/sec]", |
244 |
# |
# |
245 |
if (ref($db_config->{links}) eq 'ARRAY') { |
if (ref($db_config->{links}) eq 'ARRAY') { |
246 |
foreach my $link (@{ $db_config->{links} }) { |
foreach my $link (@{ $db_config->{links} }) { |
247 |
$log->info("adding link $database -> $link->{to} [$link->{credit}]"); |
if ($use_indexer eq 'hyperestraier') { |
248 |
$est->add_link( |
$log->info("adding link $database -> $link->{to} [$link->{credit}]"); |
249 |
from => $database, |
$indexer->add_link( |
250 |
to => $link->{to}, |
from => $database, |
251 |
credit => $link->{credit}, |
to => $link->{to}, |
252 |
); |
credit => $link->{credit}, |
253 |
|
); |
254 |
|
} else { |
255 |
|
$log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]"); |
256 |
|
} |
257 |
} |
} |
258 |
} |
} |
259 |
|
|