42 |
|
|
43 |
remove database and Hyper Estraier index before indexing |
remove database and Hyper Estraier index before indexing |
44 |
|
|
45 |
=item --only=database_name |
=item --only=database_name/input_filter |
46 |
|
|
47 |
reindex just single database (legacy name is --one) |
reindex just single database (legacy name is --one) |
48 |
|
|
49 |
|
C</input_filter> is optional part which can be C<name> |
50 |
|
or C<type> from input |
51 |
|
|
52 |
=item --config conf/config.yml |
=item --config conf/config.yml |
53 |
|
|
54 |
path to YAML configuration file |
path to YAML configuration file |
73 |
my $clean = 0; |
my $clean = 0; |
74 |
my $config = 'conf/config.yml'; |
my $config = 'conf/config.yml'; |
75 |
my $debug = 0; |
my $debug = 0; |
76 |
my $only_db_name; |
my $only_filter; |
77 |
my $force_set = 0; |
my $force_set = 0; |
78 |
my $stats = 0; |
my $stats = 0; |
79 |
|
|
81 |
"limit=i" => \$limit, |
"limit=i" => \$limit, |
82 |
"offset=i" => \$offset, |
"offset=i" => \$offset, |
83 |
"clean" => \$clean, |
"clean" => \$clean, |
84 |
"one=s" => \$only_db_name, |
"one=s" => \$only_filter, |
85 |
"only=s" => \$only_db_name, |
"only=s" => \$only_filter, |
86 |
"config" => \$config, |
"config" => \$config, |
87 |
"debug" => \$debug, |
"debug" => \$debug, |
88 |
"force-set" => \$force_set, |
"force-set" => \$force_set, |
111 |
|
|
112 |
while (my ($database, $db_config) = each %{ $config->{databases} }) { |
while (my ($database, $db_config) = each %{ $config->{databases} }) { |
113 |
|
|
114 |
next if ($only_db_name && $database !~ m/$only_db_name/i); |
my ($only_database,$only_input) = split(m#/#, $only_filter); |
115 |
|
next if ($only_database && $database !~ m/$only_database/i); |
116 |
|
|
117 |
my $indexer; |
my $indexer; |
118 |
|
|
152 |
my $db_path = $config->{webpac}->{db_path} . '/' . $database; |
my $db_path = $config->{webpac}->{db_path} . '/' . $database; |
153 |
|
|
154 |
if ($clean) { |
if ($clean) { |
155 |
$log->info("creating new database $database in $db_path"); |
$log->info("creating new database '$database' in $db_path"); |
156 |
rmtree( $db_path ) || $log->warn("can't remove $db_path: $!"); |
rmtree( $db_path ) || $log->warn("can't remove $db_path: $!"); |
157 |
} else { |
} else { |
158 |
$log->debug("working on $database in $db_path"); |
$log->info("working on database '$database' in $db_path"); |
159 |
} |
} |
160 |
|
|
161 |
my $db = new WebPAC::Store( |
my $db = new WebPAC::Store( |
182 |
|
|
183 |
foreach my $input (@inputs) { |
foreach my $input (@inputs) { |
184 |
|
|
185 |
|
next if ($only_input && $input->{name} =~ m#$only_input#i || $input->{type} =~ m#$only_input#i); |
186 |
|
|
187 |
my $type = lc($input->{type}); |
my $type = lc($input->{type}); |
188 |
|
|
189 |
die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs)); |
die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs)); |
194 |
|
|
195 |
my $input_module = $config->{webpac}->{inputs}->{$type}; |
my $input_module = $config->{webpac}->{inputs}->{$type}; |
196 |
|
|
197 |
$log->info("working on input '$input->{path}' [$input->{type}] using $input_module lookup '$input->{lookup}'"); |
$log->info("working on input '$input->{name}' in $input->{path} [type: $input->{type}] using $input_module lookup '$input->{lookup}'"); |
198 |
|
|
199 |
my $input_db = new WebPAC::Input( |
my $input_db = new WebPAC::Input( |
200 |
module => $input_module, |
module => $input_module, |
296 |
eval { $indexer->finish } if ($indexer && $indexer->can('finish')); |
eval { $indexer->finish } if ($indexer && $indexer->can('finish')); |
297 |
|
|
298 |
my $dt = time() - $start_t; |
my $dt = time() - $start_t; |
299 |
$log->info("$total_rows records indexed in " . |
$log->info("$total_rows records ", $indexer ? "indexed " : "", |
300 |
sprintf("%.2f sec [%.2f rec/sec]", |
sprintf("in %.2f sec [%.2f rec/sec]", |
301 |
$dt, ($total_rows / $dt) |
$dt, ($total_rows / $dt) |
302 |
) |
) |
303 |
); |
); |