From 498c52de5e736e4eb97b5db77120f5ca2be5abd4 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 Signed-off-by: Brendan Gallagher --- 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 293f64b..b93687d 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 b54e28c..60c48ad 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -516,6 +516,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 91d1caa..7c671cb 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -343,11 +343,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.1.4