Bug 19365: Fix search for duplicate authorities with Elasticsearch
authorEre Maijala <ere.maijala@helsinki.fi>
Sun, 16 Sep 2018 21:10:22 +0000 (00:10 +0300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 26 Nov 2018 16:11:02 +0000 (16:11 +0000)
Sponsored-by: National Library of Finland
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/AuthoritiesMarc.pm
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
Koha/SearchEngine/Elasticsearch/Search.pm

index 98d73f7..780380e 100644 (file)
@@ -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\]]);
index 254fba2..543728e 100644 (file)
@@ -523,6 +523,8 @@ our %index_field_convert = (
     'mus'     => 'rtype',
     'aud'     => 'ta',
     'hi'      => 'Host-Item-Number',
+    'at'      => 'authtype',
+    'he'      => 'Heading'
 );
 
 sub _convert_index_fields {
index b7f139f..68cb0ec 100644 (file)
@@ -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