Bug 17169: Add a facet for ccode fields to ElasticSearch
authorNick Clemens <nick@bywatersolutions.com>
Tue, 11 Oct 2016 09:01:12 +0000 (09:01 +0000)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Wed, 22 Mar 2017 19:24:22 +0000 (19:24 +0000)
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 <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>

Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
Koha/SearchEngine/Elasticsearch/Search.pm
admin/searchengine/elasticsearch/mappings.yaml
koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc
koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc

index 5946a27..fbd4370 100644 (file)
@@ -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');
index ee38dae..c3cdb15 100644 (file)
@@ -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' }
     );
index 50582a8..8d3fec4 100644 (file)
@@ -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:
index 3d0d15e..887c38c 100644 (file)
@@ -20,6 +20,7 @@
 [% IF ( facets_loo.type_label_HomeLibrary ) %]<span id="facet-home-libraries">Home libraries</span>[% END %]
 [% IF ( facets_loo.type_label_HoldingLibrary ) %]<span id="facet-holding-libraries">Holding libraries</span>[% END %]
 [% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
+[% IF facets_loo.type_label_CollectionCodes %]<span id="facet-locations">Collections</span>[% END %]
 <ul>
   [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
   [% IF ( sort_by ) %]
index e83243e..b1505b7 100644 (file)
@@ -24,6 +24,7 @@
                         [% IF facets_loo.type_label_Places %]<h5 id="facet-places">Places</h5>[% END %]
                         [% IF facets_loo.type_label_Series %]<h5 id="facet-series">Series</h5>[% END %]
                         [% IF facets_loo.type_label_ItemTypes %]<h5 id="facet-itemtypes">Item types</h5>[% END %]
+                        [% IF facets_loo.type_label_CollectionCodes %]<h5 id="facet-itemtypes">Collections</h5>[% END %]
                         [% UNLESS singleBranchMode %]
                             [% IF ( facets_loo.type_label_HomeLibrary ) %]<span id="facet-home-libraries">Home libraries</span>[% END %]
                             [% IF ( facets_loo.type_label_HoldingLibrary ) %]<span id="facet-holding-libraries">Holding libraries</span>[% END %]