From aaf574e81903a5a4e66a152b7ca33479e1f7e904 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 24 Dec 2018 12:52:53 +0000 Subject: [PATCH] Bug 22046: Simplify and unify the code for get_matches Content-Type: text/plain; charset=utf-8 To test: 1 - Stage some records for import 2 - Manage the records 3 - Use several different matching rules and note the results 4 - Apply patch 5 - Try several matching rules again and note the results have not changed 6 - Try under both search engines (Zebra and ES) Signed-off-by: Liz Rea Signed-off-by: Marcel de Rooy --- C4/Matcher.pm | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/C4/Matcher.pm b/C4/Matcher.pm index dc848048c1..9da4ce3faa 100644 --- a/C4/Matcher.pm +++ b/C4/Matcher.pm @@ -675,21 +675,14 @@ sub get_matches { warn "search failed ($query) $error"; } else { - if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { - foreach my $matched ( @{$searchresults} ) { - my ( $biblionumber_tag, $biblionumber_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber", $marcframework_used ); - my $id = ( $biblionumber_tag > 10 ) ? - $matched->field($biblionumber_tag)->subfield($biblionumber_subfield) : - $matched->field($biblionumber_tag)->data(); - $matches->{$id}->{score} += $matchpoint->{score}; - $matches->{$id}->{record} = $matched; - } - } - else { - foreach my $matched ( @{$searchresults} ) { - $matches->{$matched}->{score} += $matchpoint->{'score'}; - $matches->{$matched}->{record} = $matched; - } + foreach my $matched ( @{$searchresults} ) { + my $target_record = C4::Search::new_record_from_zebra( 'biblioserver', $matched ); + my ( $biblionumber_tag, $biblionumber_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber", $marcframework_used ); + my $id = ( $biblionumber_tag > 10 ) ? + $target_record->field($biblionumber_tag)->subfield($biblionumber_subfield) : + $target_record->field($biblionumber_tag)->data(); + $matches->{$id}->{score} += $matchpoint->{score}; + $matches->{$id}->{record} = $target_record; } } @@ -741,10 +734,8 @@ sub get_matches { }; foreach my $id ( keys %$matches ) { - my $target_record = C4::Search::new_record_from_zebra( 'biblioserver', $matches->{$id}->{record} ); - my $result = C4::Biblio::TransformMarcToKoha( $target_record, $marcframework_used ); push @results, { - record_id => $result->{biblionumber}, + record_id => $id, score => $matches->{$id}->{score} }; } -- 2.11.0