diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index 23ba2eb711..f2122fa76d 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -174,13 +174,15 @@ sub search_compat { # Convert each result into a MARC::Record my @records; + my @scores; # opac-search expects results to be put in the # right place in the array, according to $offset my $index = $offset; my $hits = $results->{'hits'}; foreach my $es_record ( @{ $hits->{'hits'} } ) { - $records[ $index++ ] = $self->decode_record_from_result( $es_record->{'_source'} ); + $records[$index] = $self->decode_record_from_result( $es_record->{'_source'} ); + $scores[ $index++ ] = $es_record->{'_score'}; } # consumers of this expect a name-spaced result, we provide the default @@ -188,6 +190,7 @@ sub search_compat { my %result; $result{biblioserver}{hits} = $hits->{'total'}; $result{biblioserver}{RECORDS} = \@records; + $result{biblioserver}{scores} = \@scores; my $facets = $self->_convert_facets( $results->{aggregations} ); if ( C4::Context->interface eq 'opac' ) { diff --git a/catalogue/search.pl b/catalogue/search.pl index 53ec963579..e4d88e9683 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -710,6 +710,7 @@ if ($hits) { ); $template->param( hits_to_paginate => $hits_to_paginate ); $template->param( SEARCH_RESULTS => \@newresults ); + $template->param( SCORES => $results_hashref->{$server}->{"scores"} ); # FIXME: no previous_page_offset when pages < 2 $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 75796aad54..7645de90ed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -680,7 +680,10 @@ [% SEARCH_RESULT.result_number | html %]. [% SEARCH_RESULT.XSLTResultsRecord | $raw %] - + [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %] + [% SET score_index = loop().index %] + + [% END %]
[% IF ( SEARCH_RESULT.norequests ) %] No holds allowed