From 369ee65d94b305169ca243134a414324be9e5ba0 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 10 Jan 2006 17:03:32 +0000 Subject: [PATCH] new version of rebuild_zebra. Should work with Perl-ZOOM, but DOES NOT WORK for me. I get : ZOOM error 10002 "Encoding failed" from diag-set 'ZOOM' help expected from indexdata... --- misc/migration_tools/rebuild_zebra.pl | 40 +++++++++------------------ 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index 9bcace143f..b0f4cc9bf7 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -46,21 +46,12 @@ eval { $Zpackage->option(databaseName => 'Koha'); # $Zpackage->send("drop"); }; -if ($@) { - print "Error dropping /CODE:", $@->code()," /MSG: ",$@->message(),"\n"; -# die; -} -# then recreate it + eval { my $Zpackage = $Zconn->package(); $Zpackage->option(databaseName => 'Koha'); -# $Zpackage->send("create"); + $Zpackage->send("create"); }; -if ($@) { - print "Error creating /CODE:", $@->code(),"\n /MSG:",$@->message(),"\n\n"; -# die; -} - my $cgidir = C4::Context->intranetdir ."/cgi-bin"; unless (opendir(DIR, "$cgidir")) { $cgidir = C4::Context->intranetdir."/"; @@ -71,25 +62,20 @@ my $sth = $dbh->prepare("select biblionumber from biblio"); $sth->execute; my $i=0; while ((my $biblionumber) = $sth->fetchrow) { - my $record = MARCgetbiblio($dbh,$biblionumber); -# my $filename = $cgidir."/zebra/biblios/BIBLIO".$biblionumber."iso2709"; -# open F,"> $filename"; -# print F $record->as_usmarc(); -# close F; + my $record = XMLgetbiblio($dbh,$biblionumber); my $Zpackage = $Zconn->package(); -# print "=>".$record->as_xml()."\n"; + $Zpackage->option(databaseName => 'Koha'); $Zpackage->option(action => "recordInsert"); - $Zpackage->option(record => $record->as_usmarc()); - eval { - $Zpackage->send("update"); - }; - if ($@) { - print "Error updating /CODE:", $@->code()," /MSG:",$@->message(),"\n"; - die; - } + $Zpackage->option(record => $record); + $Zpackage->send("update"); $Zpackage->destroy; $i++; - print "\r$i" unless ($i % 100); + print '.'; + print "$i\r" unless ($i % 100); +# exit if $i>100; } +my $Zpackage = $Zconn->package(); +$Zpackage->option(databaseName => 'Koha'); +$Zpackage->send("commit"); my $timeneeded = gettimeofday - $starttime; -print "\n$i MARC record done in $timeneeded seconds\n"; +print "\n\n$i MARC record done in $timeneeded seconds\n"; -- 2.39.5