@@ -, +, @@ field characters 35-37 or UNIMARC 101a) --- C4/Languages.pm | 14 +++++++ Koha/SearchEngine/Elasticsearch.pm | 16 ++++++++ Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + Koha/SearchEngine/Elasticsearch/Search.pm | 17 ++++---- admin/searchengine/elasticsearch/mappings.yaml | 7 ++-- .../intranet-tmpl/prog/en/includes/facets.inc | 5 ++- .../admin/searchengine/elasticsearch/mappings.tt | 46 ++++++++++++++++++++++ .../bootstrap/en/includes/opac-facets.inc | 5 ++- t/db_dependent/Languages.t | 8 +++- 9 files changed, 105 insertions(+), 14 deletions(-) --- a/C4/Languages.pm +++ a/C4/Languages.pm @@ -612,6 +612,20 @@ sub getlanguage { return $language; } +=head2 get_rfc4646_from_iso639 + + Select a language rfc4646 code given an iso639 code + +=cut + +sub get_rfc4646_from_iso639 { + + my $iso_code = shift; + my $rfc_subtag = Koha::Database->new()->schema->resultset('LanguageRfc4646ToIso639')->find({iso639_2_code=>$iso_code})->rfc4646_subtag; + return $rfc_subtag; + +} + 1; __END__ --- a/Koha/SearchEngine/Elasticsearch.pm +++ a/Koha/SearchEngine/Elasticsearch.pm @@ -479,6 +479,22 @@ sub process_error { return "Unable to perform your search. Please try again.\n"; } +sub get_facetable_fields { + my ($self) = @_; + + # These should correspond to the ES field names, as opposed to the CCL + # things that zebra uses. + my @search_field_names = qw( author itype location su-geo se subject ccode holdingbranch homebranch ln); + my @faceted_fields = Koha::SearchFields->search( + { name => { -in => \@search_field_names }, facet_order => { '!=' => undef } }, { order_by => ['facet_order'] } + ); + my @not_faceted_fields = Koha::SearchFields->search( + { name => { -in => \@search_field_names }, facet_order => undef }, { order_by => ['facet_order'] } + ); + # This could certainly be improved + return ( @faceted_fields, @not_faceted_fields ); +} + 1; __END__ --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -119,6 +119,7 @@ sub build_query { 'su-geo' => { terms => { field => "su-geo__facet" } }, se => { terms => { field => "se__facet" } }, ccode => { terms => { field => "ccode__facet" } }, + ln => { terms => { field => "ln__facet" } }, }; my $display_library_facets = C4::Context->preference('DisplayLibraryFacets'); --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ a/Koha/SearchEngine/Elasticsearch/Search.pm @@ -425,15 +425,16 @@ sub _convert_facets { # things that zebra uses. # TODO let the library define the order using the interface. my %type_to_label = ( - author => { order => 1, label => 'Authors', }, - itype => { order => 2, label => 'ItemTypes', }, - location => { order => 3, label => 'Location', }, - 'su-geo' => { order => 4, label => 'Places', }, - se => { order => 5, label => 'Series', }, - subject => { order => 6, label => 'Topics', }, - ccode => { order => 7, label => 'CollectionCodes',}, + author => { order => 1, label => 'Authors', }, + itype => { order => 2, label => 'ItemTypes', }, + location => { order => 3, label => 'Location', }, + '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' } + homebranch => { order => 9, label => 'HomeLibrary' }, + ln => { order => 10, label => 'Language' } ); # We also have some special cases, e.g. itypes that need to show the --- a/admin/searchengine/elasticsearch/mappings.yaml +++ a/admin/searchengine/elasticsearch/mappings.yaml @@ -1715,22 +1715,23 @@ biblios: ln: label: ln mappings: - - facet: '' + - facet: '1' marc_field: 008_/35-37 marc_type: marc21 sort: ~ suggestible: '' - - facet: '' + - facet: '1' marc_field: 008_/35-37 marc_type: normarc sort: ~ suggestible: '' - - facet: '' + - facet: '1' marc_field: 101a marc_type: unimarc sort: ~ suggestible: '' type: '' + facet_order: 10 local-classification: label: local-classification mappings: --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -1,4 +1,5 @@ [% USE AuthorisedValues %] +[% USE Languages %] [% IF ( opacfacets ) %] [% IF ( facets_loop ) %]
Search field | +Label | +Display | +
---|---|---|
+ [% f.name %] + | ++ [% SWITCH f.name %] + [% CASE 'author' %]Authors + [% CASE 'itype' %]Item Types + [% CASE 'location' %]Locations + [% CASE 'su-geo' %]Places + [% CASE 'se' %]Series + [% CASE 'subject' %]Topics + [% CASE 'ccode' %]Collections + [% CASE 'holdingbranch' %]Holding libraries + [% CASE 'homebranch' %]Home libraries + [% CASE 'ln' %]Language + [% CASE %][% f %] + [% END %] + | ++ [% IF f.facet_order %] + + [% ELSE %] + + [% END %] + | +