From 3d10d5c5c5299ed205601fb93b7816bcca290f67 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Tue, 17 Jan 2012 17:15:03 +0100 Subject: [PATCH] Bug 7246 add min/ofset and WHERE options to rebuild_zebra This patch reimplement a feature that is on biblibre/master for Koha-community/master It adds 4 parameters: * ofset = the ofset of record. Say 1000 to start rebuilding at the 1000th record of your database * min = how many records to export. Say 400 to export only 400 records * WHERE = add a where clause to rebuild only a given itemtype, or anything you want to filter on * l = how many items should be export with biblios. This is a usefull option when you have records with so many items that they can result in a record higher than 99999bytes, that zebra don't like at all Another improvement resulting from ofset & min limit is the rebuild_zebra_sliced.zsh that will be submitted in another patch. _sliced will slice your all database in small chunks, and, if something went wrong for a given slice, will slice the slice, and repeat, until you reach a slice size of 1, showing which record is wrong in your database. --- misc/migration_tools/rebuild_zebra.pl | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index fbfd3af..adeffb5 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -34,6 +34,10 @@ my $want_help; my $as_xml; my $process_zebraqueue; my $do_not_clear_zebraqueue; +my $item_limit; +my $min; +my $where; +my $ofset; my $verbose_logging; my $zebraidx_log_opt = " -v none,fatal,warn "; my $result = GetOptions( @@ -51,6 +55,10 @@ my $result = GetOptions( 'x' => \$as_xml, 'y' => \$do_not_clear_zebraqueue, 'z' => \$process_zebraqueue, + 'l:i' => \$item_limit, + 'where:s' => \$where, + 'min:i' => \$min, + 'ofset:i' => \$ofset, 'v' => \$verbose_logging, ); @@ -294,13 +302,21 @@ sub select_all_records { } sub select_all_authorities { - my $sth = $dbh->prepare("SELECT authid FROM auth_header"); + my $strsth=qq{SELECT authid FROM auth_header}; + $strsth.=qq{ WHERE $where } if ($where); + $strsth.=qq{ LIMIT $min } if ($min && !$ofset); + $strsth.=qq{ LIMIT $ofset,$min } if ($min && $ofset); + my $sth = $dbh->prepare($strsth); $sth->execute(); return $sth; } sub select_all_biblios { - my $sth = $dbh->prepare("SELECT biblionumber FROM biblioitems ORDER BY biblionumber"); + my $strsth = qq{ SELECT biblionumber FROM biblioitems }; + $strsth.=qq{ WHERE $where } if ($where); + $strsth.=qq{ LIMIT $min } if ($min && !$ofset); + $strsth.=qq{ LIMIT $ofset,$min } if ($ofset); + my $sth = $dbh->prepare($strsth); $sth->execute(); return $sth; } @@ -635,9 +651,19 @@ Parameters: the same records - specify -y to override this. Cannot be used with -z. + -l set a maximum number of exported items per biblio. + Doesn't work with -nosanitize. -v increase the amount of logging. Normally only warnings and errors from the indexing are shown. + -min 1234 minimum biblionumber + -ofset 1243 count biblios to process + example: -min 1000 -ofset=500 will result in a LIMIT 500,1000 (exporting 1000 records, starting by the 500th one) + note that the numbers are NOT related to biblionumber, that's the intended behaviour. + + -where let you specify a WHERE query, like itemtype='BOOK' + or something like that + -munge-config Deprecated option to try to fix Zebra config files. --help or -h show this message. -- 1.7.5.4