[Koha-patches] [PATCH] Bug 10399 - rebuild_zebra.pl should reset the indexes with -r even if zebraqueue empty

Tomas Cohen Arazi tomascohen at gmail.com
Tue Jun 4 15:22:19 CEST 2013


This patch add the reset_indexes sub to the rebuild_zebra.pl script. And changes
the scripts' logic to run it in case -r was passed and there are no records pending
on the zebraqueue table.

Regards
To+
---
 misc/migration_tools/rebuild_zebra.pl | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl
index a46526d..b5e2063 100755
--- a/misc/migration_tools/rebuild_zebra.pl
+++ b/misc/migration_tools/rebuild_zebra.pl
@@ -271,9 +271,12 @@ sub index_records {
                 if %$records_deleted;
             do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
                 if $num_records_exported;
+        } elsif ($num_records_exported or $skip_export) {
+            do_indexing($record_type, 'update', "$directory/$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt);
         } else {
-            do_indexing($record_type, 'update', "$directory/$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt)
-                if ($num_records_exported or $skip_export);
+            if ( $reset ) {
+                reset_index($record_type, $record_fmt, $zebraidx_log_opt);
+            }
         }
     }
 }
@@ -679,6 +682,19 @@ sub do_indexing {
 
 }
 
+sub reset_indexes {
+
+    my ($record_type, $record_format, $zebraidx_log_opt) = @_;
+
+    my $zebra_server  = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver';
+    my $zebra_db_name = ($record_type eq 'biblio') ? 'biblios' : 'authorities';
+    my $zebra_config  = C4::Context->zebraconfig($zebra_server)->{'config'};
+
+    system("zebraidx -c $zebra_config $zebraidx_log_opt -g $record_format -d $zebra_db_name init");
+
+}
+
+
 sub print_usage {
     print <<_USAGE_;
 $0: reindex MARC bibs and/or authorities in Zebra.
-- 
1.8.1.2



More information about the Koha-patches mailing list