52 |
|
|
53 |
=item --force-set |
=item --force-set |
54 |
|
|
55 |
force conversion C<normalize->path> in C<config.yml> from |
force conversion C<< normalize->path >> in C<config.yml> from |
56 |
C<.xml> to C<.pl> |
C<.xml> to C<.pl> |
57 |
|
|
58 |
|
=item --stats |
59 |
|
|
60 |
|
disable indexing and dump statistics about field and subfield |
61 |
|
usage for each input |
62 |
|
|
63 |
=back |
=back |
64 |
|
|
65 |
=cut |
=cut |
72 |
my $debug = 0; |
my $debug = 0; |
73 |
my $only_db_name; |
my $only_db_name; |
74 |
my $force_set = 0; |
my $force_set = 0; |
75 |
|
my $stats = 0; |
76 |
|
|
77 |
GetOptions( |
GetOptions( |
78 |
"limit=i" => \$limit, |
"limit=i" => \$limit, |
83 |
"config" => \$config, |
"config" => \$config, |
84 |
"debug" => \$debug, |
"debug" => \$debug, |
85 |
"force-set" => \$force_set, |
"force-set" => \$force_set, |
86 |
|
"stats" => \$stats, |
87 |
); |
); |
88 |
|
|
89 |
$config = LoadFile($config); |
$config = LoadFile($config); |
93 |
die "no databases in config file!\n" unless ($config->{databases}); |
die "no databases in config file!\n" unless ($config->{databases}); |
94 |
|
|
95 |
my $log = _new WebPAC::Common()->_get_logger(); |
my $log = _new WebPAC::Common()->_get_logger(); |
96 |
|
$log->info( "-" x 79 ); |
97 |
|
|
98 |
my $use_indexer = $config->{use_indexer} || 'hyperestraier'; |
my $use_indexer = $config->{use_indexer} || 'hyperestraier'; |
99 |
$log->info("using $use_indexer indexing engine..."); |
if ($stats) { |
100 |
|
$log->debug("option --stats disables update of indexing engine..."); |
101 |
|
$use_indexer = undef; |
102 |
|
} else { |
103 |
|
$log->info("using $use_indexer indexing engine..."); |
104 |
|
} |
105 |
|
|
106 |
my $total_rows = 0; |
my $total_rows = 0; |
107 |
my $start_t = time(); |
my $start_t = time(); |
112 |
|
|
113 |
my $indexer; |
my $indexer; |
114 |
|
|
115 |
my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration"); |
if ($use_indexer) { |
116 |
$indexer_config->{database} = $database; |
my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration"); |
117 |
$indexer_config->{clean} = $clean; |
$indexer_config->{database} = $database; |
118 |
$indexer_config->{label} = $db_config->{name}; |
$indexer_config->{clean} = $clean; |
119 |
|
$indexer_config->{label} = $db_config->{name}; |
120 |
if ($use_indexer eq 'hyperestraier') { |
|
121 |
|
if ($use_indexer eq 'hyperestraier') { |
122 |
# open Hyper Estraier database |
|
123 |
use WebPAC::Output::Estraier '0.10'; |
# open Hyper Estraier database |
124 |
$indexer = new WebPAC::Output::Estraier( %{ $indexer_config } ); |
use WebPAC::Output::Estraier '0.10'; |
125 |
|
$indexer = new WebPAC::Output::Estraier( %{ $indexer_config } ); |
126 |
} elsif ($use_indexer eq 'kinosearch') { |
|
127 |
|
} elsif ($use_indexer eq 'kinosearch') { |
128 |
# open KinoSearch |
|
129 |
use WebPAC::Output::KinoSearch; |
# open KinoSearch |
130 |
$indexer_config->{clean} = 1 unless (-e $indexer_config->{index_path}); |
use WebPAC::Output::KinoSearch; |
131 |
$indexer = new WebPAC::Output::KinoSearch( %{ $indexer_config } ); |
$indexer_config->{clean} = 1 unless (-e $indexer_config->{index_path}); |
132 |
|
$indexer = new WebPAC::Output::KinoSearch( %{ $indexer_config } ); |
133 |
|
|
134 |
} else { |
} else { |
135 |
$log->logdie("unknown use_indexer: $use_indexer"); |
$log->logdie("unknown use_indexer: $use_indexer"); |
136 |
|
} |
137 |
|
|
138 |
|
$log->logide("can't continue without valid indexer") unless ($indexer); |
139 |
} |
} |
140 |
|
|
|
$log->logide("can't continue without valid indexer") unless ($indexer); |
|
141 |
|
|
142 |
# |
# |
143 |
# now WebPAC::Store |
# now WebPAC::Store |
197 |
offset => $offset, |
offset => $offset, |
198 |
lookup => $lookup, |
lookup => $lookup, |
199 |
recode => $input->{recode}, |
recode => $input->{recode}, |
200 |
|
stats => $stats, |
201 |
); |
); |
202 |
$log->logdie("can't create input using $input_module") unless ($input); |
$log->logdie("can't create input using $input_module") unless ($input); |
203 |
|
|
256 |
push @{ $row->{'000'} }, $pos; |
push @{ $row->{'000'} }, $pos; |
257 |
} |
} |
258 |
|
|
259 |
my $ds = $n ? $n->data_structure($row) : |
|
260 |
WebPAC::Normalize::Set::data_structure( |
my $ds; |
261 |
|
if ($n) { |
262 |
|
$ds = $n->data_structure($row); |
263 |
|
} else { |
264 |
|
$ds = WebPAC::Normalize::Set::data_structure( |
265 |
row => $row, |
row => $row, |
266 |
rules => $rules, |
rules => $rules, |
267 |
lookup => $lookup->lookup_hash, |
lookup => $lookup->lookup_hash, |
268 |
); |
); |
269 |
|
|
270 |
|
$db->save_ds( |
271 |
|
id => $mfn, |
272 |
|
ds => $ds, |
273 |
|
prefix => $input->{name}, |
274 |
|
) if ($ds && !$stats); |
275 |
|
} |
276 |
|
|
277 |
$indexer->add( |
$indexer->add( |
278 |
id => $input->{name} . "/" . $mfn, |
id => $input->{name} . "/" . $mfn, |
279 |
ds => $ds, |
ds => $ds, |
280 |
type => $config->{$use_indexer}->{type}, |
type => $config->{$use_indexer}->{type}, |
281 |
); |
) if ($indexer); |
282 |
|
|
283 |
$total_rows++; |
$total_rows++; |
284 |
} |
} |
285 |
|
|
286 |
|
$log->info("statistics of fields usage:\n", $input_db->stats) if ($stats); |
287 |
|
|
288 |
}; |
}; |
289 |
|
|
290 |
eval { $indexer->finish } if ($indexer->can('finish')); |
eval { $indexer->finish } if ($indexer && $indexer->can('finish')); |
291 |
|
|
292 |
my $dt = time() - $start_t; |
my $dt = time() - $start_t; |
293 |
$log->info("$total_rows records indexed in " . |
$log->info("$total_rows records indexed in " . |