Merge branch 'bug_10230' into 3.14-master

This commit is contained in:
Jared Camins-Esakov 2013-05-19 08:41:05 -04:00
commit f1b122c2d0
3 changed files with 54 additions and 38 deletions

View file

@ -1036,8 +1036,12 @@ sub GetBestRecordMatch {
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT candidate_match_id
FROM import_record_matches
JOIN biblio ON ( candidate_match_id = biblionumber )
WHERE import_record_id = ?
JOIN import_records ON ( import_record_matches.import_record_id = import_records.import_record_id )
LEFT JOIN biblio ON ( candidate_match_id = biblio.biblionumber )
LEFT JOIN auth_header ON ( candidate_match_id = auth_header.authid )
WHERE import_record_matches.import_record_id = ? AND
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) )
ORDER BY score DESC, candidate_match_id DESC");
$sth->execute($import_record_id);
my ($record_id) = $sth->fetchrow_array();

View file

@ -628,51 +628,58 @@ sub get_matches {
my $QParser;
$QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
foreach my $matchpoint (@{ $self->{'matchpoints'} }) {
my @source_keys = _get_match_keys($source_record, $matchpoint);
foreach my $matchpoint ( @{ $self->{'matchpoints'} } ) {
my @source_keys = _get_match_keys( $source_record, $matchpoint );
next if scalar(@source_keys) == 0;
# build query
my $query;
my $error;
my $searchresults;
my $total_hits;
if ($QParser) {
$query = join(" || ", map { "$matchpoint->{'index'}:$_" } @source_keys);
if ( $self->{'record_type'} eq 'biblio' ) {
if ($QParser) {
$query = join( " || ",
map { "$matchpoint->{'index'}:$_" } @source_keys );
}
else {
$query = join( " or ",
map { "$matchpoint->{'index'}=$_" } @source_keys );
}
require C4::Search;
($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches, [ $self->{'record_type'} . 'server' ] );
} else {
if ($self->{'record_type'} eq 'biblio') {
$query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
require C4::Search;
($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches);
} elsif ($self->{'record_type'} eq 'authority') {
my $authresults;
my @marclist;
my @and_or;
my @excluding = [];
my @operator;
my @value;
foreach my $key (@source_keys) {
push @marclist, $matchpoint->{'index'};
push @and_or, 'or';
push @operator, 'exact';
push @value, $key;
}
require C4::AuthoritiesMarc;
($authresults, $total_hits) = C4::AuthoritiesMarc::SearchAuthorities(
\@marclist, \@and_or, \@excluding, \@operator,
\@value, 0, 20, undef, 'AuthidAsc', 1
);
foreach my $result (@$authresults) {
push @$searchresults, $result->{'authid'};
}
( $error, $searchresults, $total_hits ) =
C4::Search::SimpleSearch( $query, 0, $max_matches );
}
elsif ( $self->{'record_type'} eq 'authority' ) {
my $authresults;
my @marclist;
my @and_or;
my @excluding = [];
my @operator;
my @value;
foreach my $key (@source_keys) {
push @marclist, $matchpoint->{'index'};
push @and_or, 'or';
push @operator, 'exact';
push @value, $key;
}
require C4::AuthoritiesMarc;
( $authresults, $total_hits ) =
C4::AuthoritiesMarc::SearchAuthorities(
\@marclist, \@and_or, \@excluding, \@operator,
\@value, 0, 20, undef,
'AuthidAsc', 1
);
foreach my $result (@$authresults) {
push @$searchresults, $result->{'authid'};
}
}
if (defined $error ) {
if ( defined $error ) {
warn "search failed ($query) $error";
} else {
foreach my $matched (@{$searchresults}) {
}
else {
foreach my $matched ( @{$searchresults} ) {
$matches{$matched} += $matchpoint->{'score'};
}
}

View file

@ -365,12 +365,17 @@ sub import_records_list {
my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
my $match_citation = '';
my $match_id;
if ($#$match > -1) {
if ($match->[0]->{'record_type'} eq 'biblio') {
$match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
$match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
$match_id = $match->[0]->{'biblionumber'};
} elsif ($match->[0]->{'record_type'} eq 'auth') {
$match_citation .= $match->[0]->{'authorized_heading'} if defined($match->[0]->{'authorized_heading'});
if (defined($match->[0]->{'authorized_heading'})) {
$match_citation .= $match->[0]->{'authorized_heading'};
$match_id = $match->[0]->{'candidate_match_id'};
}
}
}
@ -383,7 +388,7 @@ sub import_records_list {
overlay_status => $record->{'overlay_status'},
# Sorry about the match_id being from the "biblionumber" field;
# as it turns out, any match id will go in biblionumber
match_id => $#$match > -1 ? $match->[0]->{'biblionumber'} : 0,
match_id => $match_id,
match_citation => $match_citation,
match_score => $#$match > -1 ? $match->[0]->{'score'} : 0,
record_type => $record->{'record_type'},