From 97ef907c0357054f35ed9ee1e365e59f8ebf0193 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 29 Apr 2019 11:27:49 +0200 Subject: [PATCH] Bug 18829: Elasticsearch - Add ability to view the ES indexed record This is groundwork - we need to make the display prettier, but for now it does at least dump the record into the template We probably also need a swtich to enable/disable this - or just move it into the left hand tabs? --- catalogue/detail.pl | 14 +++++++++++ .../prog/en/modules/catalogue/detail.tt | 28 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 027ca52..b446d6c 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -46,6 +46,8 @@ use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; use Koha::Virtualshelves; +use LWP::Simple; +use Koha::SearchEngine::Elasticsearch; use Koha::Plugins; my $query = CGI->new(); @@ -543,4 +545,16 @@ $template->param (countdeletedorders => $count_deletedorders_using_biblio); $template->param (basketsorders => \@baskets_orders); $template->param (basketsdeletedorders => \@baskets_deletedorders); +if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { + my $es_conf = Koha::SearchEngine::Elasticsearch->new({index=>'biblios'})->get_elasticsearch_params(); + my $es_url; + my $es_record; + foreach my $es_node ( @{$es_conf->{nodes}} ){ + $es_url = "http://".$es_node."/".$es_conf->{index_name}."/data/$biblionumber"; + $es_record = get($es_url); + last if defined $es_record; #can quit once we find the record (should be same in any node) + } + $template->param( esrecord => $es_record ); +} + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 6520134..3f13207 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -169,6 +169,7 @@ [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %] [% END %] +[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
  • Elasticsearch Record
  • [% END %] [% items_table_block_iter = 0 %] @@ -698,6 +699,18 @@ [% END %] +[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %] +
    +
    + [% IF esrecord %] +

    [% esrecord %]

    + + [% ELSE %] +

    "This record was not found in the ES index"

    + [% END %] +
    +[% END %] +
    @@ -943,6 +956,21 @@ [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() { verify_images(); });[% END %] + + [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' && 1==0 %] + function ESRecord (biblionumber) { + $.getJSON("http://localhost:9200/koha_kohadev_biblios/data/", biblionumber, function( data ){ + $.each( data, function( key, val ) { + console.log("key "+key+"val "+val); + }); + }); + } + $(document).ready( function(){ + var esid = [% biblionumber %]; + ESRecord( esid ); + }); + [% END %] + [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %] -- 2.7.4