From 306250e4967aa27dbb9807e622065ed76dd5048c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 11 Oct 2016 09:01:12 +0000 Subject: [PATCH] Bug 17169: Add a facet for ccode fields to ElasticSearch To test: 1 - Apply patch 2 - Backup your db 3 - Drop and create a new db to ensure your mappings are refreshed from the patch 4 - add some titles with items with collection codes 5 - search and see collection code facets 6 - sign off Work to be done: 1 - Replace codes with descriptions Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Brendan A Gallagher --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + Koha/SearchEngine/Elasticsearch/Search.pm | 2 +- admin/searchengine/elasticsearch/mappings.yaml | 9 +++++++++ koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc | 1 + .../opac-tmpl/bootstrap/en/includes/opac-facets.inc | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 5946a272ac..fbd4370b64 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -118,6 +118,7 @@ sub build_query { location => { terms => { field => "location__facet" } }, 'su-geo' => { terms => { field => "su-geo__facet" } }, se => { terms => { field => "se__facet" } }, + ccode => { terms => { field => "ccode__facet" } }, }; my $display_library_facets = C4::Context->preference('DisplayLibraryFacets'); diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm index ee38daec17..c3cdb15dad 100644 --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ b/Koha/SearchEngine/Elasticsearch/Search.pm @@ -146,7 +146,6 @@ sub search_compat { $servers, $results_per_page, $offset, $expanded_facet, $branches, $query_type, $scan ) = @_; - my %options; $options{offset} = $offset; $options{expanded_facet} = $expanded_facet; @@ -408,6 +407,7 @@ sub _convert_facets { 'su-geo' => { order => 4, label => 'Places', }, se => { order => 5, label => 'Series', }, subject => { order => 6, label => 'Topics', }, + ccode => { order => 7, label => 'CollectionCodes',}, holdingbranch => { order => 8, label => 'HoldingLibrary' }, homebranch => { order => 9, label => 'HomeLibrary' } ); diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml index 50582a8b4e..8d3fec429d 100644 --- a/admin/searchengine/elasticsearch/mappings.yaml +++ b/admin/searchengine/elasticsearch/mappings.yaml @@ -1255,6 +1255,15 @@ biblios: sort: ~ suggestible: '' type: '' + ccode: + label: collection-code + mappings: + - facet: '1' + marc_field: '9528' + marc_type: marc21 + sort: ~ + suggestible: '' + type: '' control-number: label: control-number mappings: diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc index 3d0d15e036..887c38c919 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -20,6 +20,7 @@ [% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %] [% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %] [% IF facets_loo.type_label_Location %]Locations[% END %] +[% IF facets_loo.type_label_CollectionCodes %]Collections[% END %]
    [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %] [% IF ( sort_by ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc index e83243e598..b1505b7c61 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc @@ -24,6 +24,7 @@ [% IF facets_loo.type_label_Places %]
    Places
    [% END %] [% IF facets_loo.type_label_Series %]
    Series
    [% END %] [% IF facets_loo.type_label_ItemTypes %]
    Item types
    [% END %] + [% IF facets_loo.type_label_CollectionCodes %]
    Collections
    [% END %] [% UNLESS singleBranchMode %] [% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %] [% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %] -- 2.39.5