# Suite 330, Boston, MA 02111-1307 USA
use strict;
+use warnings;
+
use C4::Context;
use MARC::Record;
use C4::Search;
# build query
my $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
# FIXME only searching biblio index at the moment
- my ($error, $searchresults, $total_hits) = SimpleSearch($query);
+ my ($error, $searchresults, $total_hits) = SimpleSearch($query, 0, $max_matches);
warn "search failed ($query) $error" if $error;
foreach my $matched (@$searchresults) {
last FIELD if $j > 0 and $check_only_first_repeat;
last FIELD if $i > 0 and $j > $#keys;
my $key = "";
+ my $string;
if ($field->is_control_field()) {
- if ($component->{'length'}) {
- $key = _normalize(substr($field->data(), $component->{'offset'}, $component->{'length'}))
- # FIXME normalize, substr
- } else {
- $key = _normalize($field->data());
- }
+ $string=$field->data();
} else {
foreach my $subfield ($field->subfields()) {
if (exists $component->{'subfields'}->{$subfield->[0]}) {
- $key .= " " . $subfield->[1];
+ $string .= " " . $subfield->[1];
}
}
- $key = _normalize($key);
+ }
+ if ($component->{'length'}>0) {
+ $string= substr($string, $component->{'offset'}, $component->{'length'});
+ # FIXME normalize, substr
+ } elsif ($component->{'offset'}) {
+ $string= substr($string, $component->{'offset'});
}
+ $key = _normalize($string);
if ($i == 0) {
push @keys, $key if $key;
} else {
}
}
return @keys;
-
}
# FIXME - default normalizer
sub _normalize {
my $value = uc shift;
+ $value =~ s/[.;:,\]\[\)\(\/'"]//g;
$value =~ s/^\s+//;
- $value =~ s/^\s+$//;
+ #$value =~ s/^\s+$//;
+ $value =~ s/\s+$//;
$value =~ s/\s+/ /g;
- $value =~ s/[.;,\]\[\)\(\/"']//g;
+ #$value =~ s/[.;,\]\[\)\(\/"']//g;
return $value;
}