[Koha-zebra] zebra extended services problem

Paul POULAIN paul.poulain at free.fr
Tue Jan 3 14:45:51 CET 2006


Hi,

I begin to play with ZOOM::package and get some unclear (to me) errors...

Here is my perl code, that will build the zebra DB from the Koha DB 
(once it will work ;-) ) :
> my $dbh = C4::Context->dbh;
> my $Zconn;
> eval {
> 	$Zconn = new ZOOM::Connection('localhost','2100');
> };
> if ($@) {
> 	print "Error ", $@->code()," : ",$@->message();"\n";
> }
> 
> # first, drop Zebra DB
> eval {
> my $Zpackage = $Zconn->package();
> 	$Zpackage->send("drop");
> };
> if ($@) {
> 	print "Error dropping /CODE:", $@->code()," /MSG: ",$@->message();"\n";
> }
> # then recreate it
> eval {
> 	my $Zpackage = $Zconn->package();
> 	$Zpackage->option(databaseName => 'Koha');
> 	$Zpackage->send("create");
> };
> if ($@) {
> 	print "Error creating /CODE:", $@->code()," /MSG:",$@->message();"\n\n";
> }
> 
> my $cgidir = C4::Context->intranetdir ."/cgi-bin";
> my $starttime = gettimeofday;
> my $sth = $dbh->prepare("select biblionumber from biblio");
> $sth->execute;
> my $i=0;
> while ((my $biblionumber) = $sth->fetchrow) {
> 	my $record = MARCgetbiblio($dbh,$biblionumber);
> 	my $Zpackage = $Zconn->package();
> 	$Zpackage->option(action => "recordInsert");
> 	$Zpackage->option(record => $record->as_usmarc);
> 	eval {
> 		$Zpackage->send("update");
> 	};
> 	if ($@) {
> 	print "Error updating ", $@->code()," => ",$@->message(),"\n";
> 	}
> 	$Zpackage->destroy;
> 	$i++;
> 	print "\r$i" unless ($i % 100);
> }
> my $timeneeded = gettimeofday - $starttime;

At 1st, this the drop/create database did not work.
I added perm.anonymous: rw
in zebra.cfg and it's OK

But now, I get a :
Error updating 10002 => Encoding failed

I bet it's
 > 	$Zpackage->option(record => $record->as_usmarc);
that is not the correct option, but I don't know how code the MARC 
record and transmit it to zebra !

Thanks for your directions.
-- 
Paul POULAIN
Consultant indépendant en logiciels libres
responsable francophone de koha (SIGB libre http://www.koha-fr.org)





More information about the Koha-zebra mailing list