Koha/misc/migration_tools/rebuild_zebra.pl
tipaul dba37f38e7 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
<snip>
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
2005-08-11 16:35:54 +00:00

55 lines
1.2 KiB
Perl
Executable file

#!/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 <<EOF
script to write files for zebra DB reindexing. Once it's done, run zebraidx update biblios
run the script with -c to confirm the reindexing.
EOF
;#'
die;
}
$|=1; # flushes output
my $dbh = C4::Context->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";