Bug 12368: Rebuild Zebra improvement: allow to specify a DB table

Currently the --where parameter only allow to specify a condition on
fields in the biblioitems table.
For some needs it would be great to specify a condition on the field in
the items table.

The use case is the following: you want to reindex biblios with items
modified since a specific timestamp.

Test plan:
1/ Pick an item randomly in your catalogue
2/ Edit it and save
3/ Note that the items.timestamp has been set to today but not the
biblioitems.timestamp
4/ launch rebuild_zebra without the new parameter
  perl misc/migration_tools/rebuild_zebra.pl -b -v --where
  "timestamp >= XXX"
where XXX is the today date (e.g. "2014-06-05 00:00:00").
Note that the biblio has not been indexed.
5/ launch rebuild_zebra using the new parameter:
  perl misc/migration_tools/rebuild_zebra.pl -b -v -t items --where
  "timestamp >= XXX"
Note the biblio has been indexed.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2014-06-04 17:03:51 +02:00 committed by Tomas Cohen Arazi
parent ca00f0ddae
commit 2d9c221abc
1 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,7 @@ my $run_as_root;
my $run_user = (getpwuid($<))[0];
my $wait_for_lock = 0;
my $use_flock;
my $table = 'biblioitems';
my $verbose_logging = 0;
my $zebraidx_log_opt = " -v none,fatal,warn ";
@ -75,6 +76,7 @@ my $result = GetOptions(
'v+' => \$verbose_logging,
'run-as-root' => \$run_as_root,
'wait-for-lock' => \$wait_for_lock,
't|table:s' => \$table,
);
if (not $result or $want_help) {
@ -442,7 +444,10 @@ sub select_all_authorities {
}
sub select_all_biblios {
my $strsth = qq{ SELECT biblionumber FROM biblioitems };
$table = 'biblioitems'
if $table ne 'items'
and $table ne 'biblio';
my $strsth = qq{ SELECT biblionumber FROM $table };
$strsth.=qq{ WHERE $where } if ($where);
$strsth.=qq{ LIMIT $length } if ($length && !$offset);
$strsth.=qq{ LIMIT $offset,$length } if ($offset);
@ -918,6 +923,9 @@ Parameters:
to wait for the lock to free and then continue
processing the rebuild request,
--table specify a table (can be items, biblioitems or biblio) to retrieve biblionumber to index.
biblioitems is the default value.
--help or -h show this message.
_USAGE_
}