From 94d23aa6fbed50ebf3ccb8c4a84e40d34a57f3eb Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 20 Sep 2016 19:55:04 +0000 Subject: [PATCH] Bug 18514 : Adding search capabilities for Overdrive results in Koha To test 1/ Apply the first patch and run the script in it 2/ Search, notice no Overdrive results showing 3/ Search again, now you should get results in the OPAC results page --- Koha/SearchEngine/Elasticsearch/Search.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index cec1cb7fb6..9f7698c58c 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -158,9 +158,23 @@ sub search_compat { $index = $offset; # opac-search expects results to be put in the # right place in the array, according to $offset $results->each(sub { + my $marc; # The results come in an array for some reason - my $marc_json = $_[0]->{record}; - my $marc = $self->json2marc($marc_json); + unless (ref($_[0]->{'Local-number'}) ){ +# shift this to overdrive stuff + $marc = MARC::Record->new(); + $marc->add_fields( + [ 245, "1", " ", a => $_[0]->{title}, b=> $_[0]->{subtitle} ], + [ 100, "", "", a => $_[0]->{'primaryCreator'}->{'name'}], + [ 999, "", "", c => $_[0]->{'Local-number'}], + [ 999, "", "", d => $_[0]->{'Local-number'}], + [ 999, "", "", a => 'ExtOverdrive' ], + ); + } + else { + my $marc_json = $_[0]->{record}; + $marc = $self->json2marc($marc_json); + } $records[$index++] = $marc; }); # consumers of this expect a name-spaced result, we provide the default -- 2.13.3