From 58ee54053fb7abc8a6d4e26eabf25b1b430d97e6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 2 Nov 2020 14:59:33 +0000 Subject: [PATCH] Bug 11175: Add Elasticsearch support Signed-off-by: Nick Clemens Signed-off-by: Pasi Kallinen Signed-off-by: Martin Renvoize --- C4/XSLT.pm | 7 ++++++- Koha/Biblio.pm | 5 ++--- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + admin/searchengine/elasticsearch/mappings.yaml | 9 +++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index b151b7b892..cf96229d59 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -282,9 +282,14 @@ sub XSLTParse4Display { if ( $biblio->components() ) { my @componentPartRecordXML = (''); for my $cb ( @{ $biblio->components() } ) { + if( ref $cb eq 'MARC::Record'){ + $cb = $cb->as_xml_record(); + } else { + $cb = decode('utf8', $cb); + } # Remove the xml header $cb =~ s/^<\?xml.*?\?>//; - push @componentPartRecordXML, decode('utf8', $cb); + push @componentPartRecordXML,$cb; } push @componentPartRecordXML, ''; $partsxml = join "\n", @componentPartRecordXML; diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index f306d29664..432d67f514 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -524,12 +524,11 @@ sub components { $searchstr = "rcn='".$pf001->data()."'"; } else { # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001') - $searchstr = "(rcn='".$pf001->data()."' and cni='".$pf003->data()."')"; - $searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'"; + $searchstr = "(rcn='".$pf001->data()."' AND cni='".$pf003->data()."')"; + $searchstr .= " OR rcn='".$pf003->data()." ".$pf001->data()."'"; } my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef ); - $self->{_components} = $results if ( defined($results) && scalar(@$results) ); } else { warn "Record $self->id has no 001"; diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 2a0775d386..ab292b1379 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -81,6 +81,7 @@ our %index_field_convert = ( 'nt' => 'note', 'notes' => 'note', 'rcn' => 'record-control-number', + 'cni' => 'control-number-identifier', 'su' => 'subject', 'su-to' => 'subject', #'su-geo' => 'subject', diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml index 292e9ac475..c1173a37ec 100644 --- a/admin/searchengine/elasticsearch/mappings.yaml +++ b/admin/searchengine/elasticsearch/mappings.yaml @@ -1621,6 +1621,15 @@ biblios: sort: ~ suggestible: '' type: '' + control-number-identifier: + label: control-number-identifier + mappings: + - facet: '' + marc_field: 003 + marc_type: marc21 + sort: ~ + suggestible: '' + type: '' copydate: label: copydate mappings: -- 2.20.1