From dba37f38e76f81dda05d2e837176757a91636ef6 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 11 Aug 2005 16:35:54 +0000 Subject: [PATCH] This script can be use to rebuild the zebra DB. It stores all koha MARC records in iso2709, in the bilbios directory. After that, you just have to "zebraidx update biblios" I tried on a 9900 DB, here are the results : [paul@bureau migration_tools]$ ./rebuild_zebra.pl -c 9900 9903 MARC record done in 37.9104120731354 seconds [paul@bureau zebra]$ zebraidx update biblios 18:31:24-11/08 zebraidx(20348) [log] Iterations . . . 144575 18:31:24-11/08 zebraidx(20348) [log] Distinct words . 39891 18:31:24-11/08 zebraidx(20348) [log] Updates. . . . . 46 18:31:24-11/08 zebraidx(20348) [log] Deletions. . . . 2 18:31:24-11/08 zebraidx(20348) [log] Insertions . . . 39843 18:31:24-11/08 zebraidx(20348) [log] zebra_register_close p=0x8104cf8 18:31:25-11/08 zebraidx(20348) [log] Records: 9887 i/u/d 9881/6/0 18:31:25-11/08 zebraidx(20348) [log] user/system: 531/145 18:31:25-11/08 zebraidx(20348) [log] zebra_stop 18:31:25-11/08 zebraidx(20348) [log] zebraidx times: 11.33 5.31 1.45 --- misc/migration_tools/rebuild_zebra.pl | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 misc/migration_tools/rebuild_zebra.pl diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl new file mode 100755 index 0000000000..3a15e37fff --- /dev/null +++ b/misc/migration_tools/rebuild_zebra.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# small script that import an iso2709 file into koha 2.0 + +use strict; + +# Koha modules used +use MARC::File::USMARC; +use MARC::Record; +use MARC::Batch; +use C4::Context; +use C4::Biblio; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my ( $input_marc_file, $number) = ('',0); +my ($confirm); +GetOptions( + 'c' => \$confirm, +); + +unless ($confirm) { + print <dbh; +my $cgidir = C4::Context->intranetdir ."/cgi-bin"; +unless (opendir(DIR, "$cgidir")) { + $cgidir = C4::Context->intranetdir."/"; +} + +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 $filename = $cgidir."/zebra/biblios/BIBLIO".$biblionumber."iso2709"; + open F,"> $filename"; + print F $record->as_usmarc(); + close F; + $i++; + print "\r$i" unless ($i % 100); +} +my $timeneeded = gettimeofday - $starttime; +print "\n$i MARC record done in $timeneeded seconds\n"; -- 2.39.2