From 078e6b5b0f8c9476363da6b6795a0960c1e97c4d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 20 Jun 2017 14:57:29 +0000 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 | 30 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 3a632b6..fed153f 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -47,6 +47,8 @@ use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; use Koha::Virtualshelves; +use LWP::Simple; +use Koha::SearchEngine::Elasticsearch; my $query = CGI->new(); @@ -519,4 +521,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 1c26c37..88a7845 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -232,6 +232,23 @@ function verify_images() { [% 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 %] + + + //]]> @@ -613,6 +630,7 @@ function verify_images() { [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %] [% END %] +[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %]
  • Elasticsearch Record
  • [% END %] [% items_table_block_iter = 0 %] @@ -1108,6 +1126,18 @@ function verify_images() { [% END %] +[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' ) %] +
    +
    + [% IF esrecord %] +

    [% esrecord %]

    + + [% ELSE %] +

    "This record was not found in the ES index"

    + [% END %] +
    +[% END %] +
    -- 2.1.4