From 0d7a4aafd037ae6eb1e75acf353ff4584204b64e Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Wed, 26 Sep 2007 12:26:30 +0200 Subject: [PATCH] BUGFIX : NoZebra indexing was wrong for accented words Signed-off-by: Chris Cormack --- C4/Biblio.pm | 28 ++++++++++----------- misc/migration_tools/rebuild_nozebra.pl | 33 +++++++++++++------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index b335ce2ffa..ceb906f9b2 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3089,25 +3089,25 @@ sub _AddBiblioNoZebra { next unless $_; # skip empty values (multiple spaces) # if the entry is already here, improve weight # warn "managing $_"; - if ($result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/) { + if ($result{$key}->{"$_"} =~ /$biblionumber,$title\-(\d);/) { my $weight=$1+1; - $result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//; - $result{$key}->{$_} .= "$biblionumber,$title-$weight;"; + $result{$key}->{"$_"} =~ s/$biblionumber,$title\-(\d);//; + $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; } else { # get the value if it exist in the nozebra table, otherwise, create it $sth2->execute($server,$key,$_); my $existing_biblionumbers = $sth2->fetchrow; # it exists if ($existing_biblionumbers) { - $result{$key}->{$_} =$existing_biblionumbers; + $result{$key}->{"$_"} =$existing_biblionumbers; my $weight=$1+1; - $result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//; - $result{$key}->{$_} .= "$biblionumber,$title-$weight;"; + $result{$key}->{"$_"} =~ s/$biblionumber,$title\-(\d);//; + $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; # create a new ligne for this entry } else { # warn "INSERT : $server / $key / $_"; $dbh->do('INSERT INTO nozebra SET server='.$dbh->quote($server).', indexname='.$dbh->quote($key).',value='.$dbh->quote($_)); - $result{$key}->{$_}.="$biblionumber,$title-1;"; + $result{$key}->{"$_"}.="$biblionumber,$title-1;"; } } } @@ -3121,24 +3121,24 @@ sub _AddBiblioNoZebra { foreach (split / /,$line) { next unless $_; # skip empty values (multiple spaces) # if the entry is already here, improve weight - if ($result{'__RAW__'}->{$_} =~ /$biblionumber,$title\-(\d);/) { + if ($result{'__RAW__'}->{"$_"} =~ /$biblionumber,$title\-(\d);/) { my $weight=$1+1; - $result{'__RAW__'}->{$_} =~ s/$biblionumber,$title\-(\d);//; - $result{'__RAW__'}->{$_} .= "$biblionumber,$title-$weight;"; + $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,$title\-(\d);//; + $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; } else { # get the value if it exist in the nozebra table, otherwise, create it $sth2->execute($server,'__RAW__',$_); my $existing_biblionumbers = $sth2->fetchrow; # it exists if ($existing_biblionumbers) { - $result{'__RAW__'}->{$_} =$existing_biblionumbers; + $result{'__RAW__'}->{"$_"} =$existing_biblionumbers; my $weight=$1+1; - $result{'__RAW__'}->{$_} =~ s/$biblionumber,$title\-(\d);//; - $result{'__RAW__'}->{$_} .= "$biblionumber,$title-$weight;"; + $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,$title\-(\d);//; + $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; # create a new ligne for this entry } else { $dbh->do('INSERT INTO nozebra SET server='.$dbh->quote($server).', indexname="__RAW__",value='.$dbh->quote($_)); - $result{'__RAW__'}->{$_}.="$biblionumber,$title-1;"; + $result{'__RAW__'}->{"$_"}.="$biblionumber,$title-1;"; } } } diff --git a/misc/migration_tools/rebuild_nozebra.pl b/misc/migration_tools/rebuild_nozebra.pl index 63c8ffb4d1..43a6e5a347 100755 --- a/misc/migration_tools/rebuild_nozebra.pl +++ b/misc/migration_tools/rebuild_nozebra.pl @@ -116,14 +116,15 @@ while (my ($biblionumber) = $sth->fetchrow) { # ... and split in words foreach (split / /,$line) { next unless $_; # skip empty values (multiple spaces) + # remove any accented char # if the entry is already here, improve weight - if ($result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/) { + if ($result{$key}->{"$_"} =~ /$biblionumber,$title\-(\d);/) { my $weight=$1+1; - $result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//; - $result{$key}->{$_} .= "$biblionumber,$title-$weight;"; + $result{$key}->{"$_"} =~ s/$biblionumber,$title\-(\d);//; + $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; # otherwise, create it, with weight=1 } else { - $result{$key}->{$_}.="$biblionumber,$title-1;"; + $result{$key}->{"$_"}.="$biblionumber,$title-1;"; } } } @@ -135,13 +136,13 @@ while (my ($biblionumber) = $sth->fetchrow) { foreach (split / /,$line) { next unless $_; # warn $record->as_formatted."$_ =>".$title; - if ($result{__RAW__}->{$_} =~ /$biblionumber,$title\-(\d);/) { + if ($result{__RAW__}->{"$_"} =~ /$biblionumber,$title\-(\d);/) { my $weight=$1+1; # $weight++; - $result{__RAW__}->{$_} =~ s/$biblionumber,$title\-(\d);//; - $result{__RAW__}->{$_} .= "$biblionumber,$title-$weight;"; + $result{__RAW__}->{"$_"} =~ s/$biblionumber,$title\-(\d);//; + $result{__RAW__}->{"$_"} .= "$biblionumber,$title-$weight;"; } else { - $result{__RAW__}->{$_}.="$biblionumber,$title-1;"; + $result{__RAW__}->{"$_"}.="$biblionumber,$title-1;"; } } } @@ -219,13 +220,13 @@ while (my ($authid) = $sth->fetchrow) { foreach (split / /,$line) { next unless $_; # skip empty values (multiple spaces) # if the entry is already here, improve weight - if ($result{$key}->{$_} =~ /$authid,$title\-(\d);/) { + if ($result{$key}->{"$_"} =~ /$authid,$title\-(\d);/) { my $weight=$1+1; - $result{$key}->{$_} =~ s/$authid,$title\-(\d);//; - $result{$key}->{$_} .= "$authid,$title-$weight;"; + $result{$key}->{"$_"} =~ s/$authid,$title\-(\d);//; + $result{$key}->{"$_"} .= "$authid,$title-$weight;"; # otherwise, create it, with weight=1 } else { - $result{$key}->{$_}.="$authid,$title-1;"; + $result{$key}->{"$_"}.="$authid,$title-1;"; } } } @@ -237,13 +238,13 @@ while (my ($authid) = $sth->fetchrow) { foreach (split / /,$line) { next unless $_; # warn $record->as_formatted."$_ =>".$title; - if ($result{__RAW__}->{$_} =~ /$authid,$title\-(\d);/) { + if ($result{__RAW__}->{"$_"} =~ /$authid,$title\-(\d);/) { my $weight=$1+1; # $weight++; - $result{__RAW__}->{$_} =~ s/$authid,$title\-(\d);//; - $result{__RAW__}->{$_} .= "$authid,$title-$weight;"; + $result{__RAW__}->{"$_"} =~ s/$authid,$title\-(\d);//; + $result{__RAW__}->{"$_"} .= "$authid,$title-$weight;"; } else { - $result{__RAW__}->{$_}.="$authid,$title-1;"; + $result{__RAW__}->{"$_"}.="$authid,$title-1;"; } } } -- 2.39.5