From a4c02b53cd0bbc8f646533a8ecb5be34709deffa Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Mon, 17 Sep 2018 00:10:22 +0300 Subject: [PATCH] Bug 19365: Fix search for duplicate authorities with Elasticsearch Sponsored-by: National Library of Finland Signed-off-by: Brendan Gallagher Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- C4/AuthoritiesMarc.pm | 2 +- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 2 ++ Koha/SearchEngine/Elasticsearch/Search.pm | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 98d73f7892..780380ece8 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -760,7 +760,7 @@ sub FindDuplicateAuthority { if ($QParser) { $op = '&&'; } else { - $op = 'and'; + $op = 'AND'; } my $query='at:'.$authtypecode.' '; my $filtervalues=qr([\001-\040\Q!'"`#$%&*+,-./:;<=>?@(){[}_|~\E\]]); diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 254fba2c9e..543728e841 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -523,6 +523,8 @@ our %index_field_convert = ( 'mus' => 'rtype', 'aud' => 'ta', 'hi' => 'Host-Item-Number', + 'at' => 'authtype', + 'he' => 'Heading' ); sub _convert_index_fields { diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index b7f139f1c1..68cb0eca54 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -344,11 +344,11 @@ sub simple_search_compat { } my $results = $self->search($query, undef, $max_results, %options); my @records; - $results->each(sub { - my $marc = $self->decode_record_from_result(@_); - push @records, $marc; - }); - return (undef, \@records, $results->total); + my $hits = $results->{'hits'}; + foreach my $es_record (@{$hits->{'hits'}}) { + push @records, $self->decode_record_from_result($es_record->{'_source'}); + } + return (undef, \@records, $hits->{'total'}); } =head2 extract_biblionumber -- 2.39.5