View | Details | Raw Unified | Return to bug 33139
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +4 lines)
Lines 1056-1061 sub _get_marc_mapping_rules { Link Here
1056
            # boolean gets special handling, if value doesn't exist for a field,
1056
            # boolean gets special handling, if value doesn't exist for a field,
1057
            # it is set to false
1057
            # it is set to false
1058
            $rules->{defaults}->{$name} = 'false';
1058
            $rules->{defaults}->{$name} = 'false';
1059
            if ($facet) {
1060
                $rules->{defaults}->{"${name}__facet"} = 'false';
1061
            }
1059
        }
1062
        }
1060
1063
1061
        if ($marc_field =~ $field_spec_regexp) {
1064
        if ($marc_field =~ $field_spec_regexp) {
Lines 1369-1375 sub get_facetable_fields { Link Here
1369
1372
1370
    # These should correspond to the ES field names, as opposed to the CCL
1373
    # These should correspond to the ES field names, as opposed to the CCL
1371
    # things that zebra uses.
1374
    # things that zebra uses.
1372
    my @search_field_names = qw( author itype location su-geo title-series subject ccode holdingbranch homebranch ln );
1375
    my @search_field_names = qw( author itype location su-geo title-series subject ccode holdingbranch homebranch ln has-eresource only-print );
1373
    my @faceted_fields = Koha::SearchFields->search(
1376
    my @faceted_fields = Koha::SearchFields->search(
1374
        { name => { -in => \@search_field_names }, facet_order => { '!=' => undef } }, { order_by => ['facet_order'] }
1377
        { name => { -in => \@search_field_names }, facet_order => { '!=' => undef } }, { order_by => ['facet_order'] }
1375
    )->as_list;
1378
    )->as_list;
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (+1 lines)
Lines 233-238 sub build_query { Link Here
233
        'title-series' => { terms => { field => "title-series__facet", size => $size } },
233
        'title-series' => { terms => { field => "title-series__facet", size => $size } },
234
        ccode          => { terms => { field => "ccode__facet", size => $size } },
234
        ccode          => { terms => { field => "ccode__facet", size => $size } },
235
        ln             => { terms => { field => "ln__facet", size => $size } },
235
        ln             => { terms => { field => "ln__facet", size => $size } },
236
        'has-eresource' => { terms => { field => "has-eresource__facet", size => $size } }
236
    };
237
    };
237
238
238
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
239
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-3 / +8 lines)
Lines 454-463 sub _convert_facets { Link Here
454
        holdingbranch  => 'HoldingLibrary',
454
        holdingbranch  => 'HoldingLibrary',
455
        homebranch     => 'HomeLibrary',
455
        homebranch     => 'HomeLibrary',
456
        ln             => 'Language',
456
        ln             => 'Language',
457
        'has-eresource' => 'HasEresource',
458
        'only-print'   => 'OnlyPrint'
457
    );
459
    );
458
    my @facetable_fields =
460
    my @facetable_fields =
459
      Koha::SearchEngine::Elasticsearch->get_facetable_fields;
461
        Koha::SearchEngine::Elasticsearch->get_facetable_fields;
460
    for my $f (@facetable_fields) {
462
463
        for my $f (@facetable_fields) {
461
        next unless defined $f->facet_order;
464
        next unless defined $f->facet_order;
462
        $type_to_label{ $f->name } =
465
        $type_to_label{ $f->name } =
463
          { order => $f->facet_order, label => $label{ $f->name } };
466
          { order => $f->facet_order, label => $label{ $f->name } };
Lines 495-501 sub _convert_facets { Link Here
495
            next unless length($t); # FIXME Currently we cannot search for an empty faceted field i.e. ln:"" to find records missing languages, though ES does count them correctly
498
            next unless length($t); # FIXME Currently we cannot search for an empty faceted field i.e. ln:"" to find records missing languages, though ES does count them correctly
496
            my $c = $term->{doc_count};
499
            my $c = $term->{doc_count};
497
            my $label;
500
            my $label;
498
            if ( exists( $special{$type} ) ) {
501
            if ($type eq 'has-eresource') {
502
                $t = $t && $t ne 'false' ? 'true' : 'false';
503
            } elsif ( exists( $special{$type} ) ) {
499
                $label = $special{$type}->{$t} // $t;
504
                $label = $special{$type}->{$t} // $t;
500
            }
505
            }
501
            else {
506
            else {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (+12 lines)
Lines 43-48 Link Here
43
[% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
43
[% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
44
[% IF facets_loo.type_label_CollectionCodes %]<span id="facet-collections">Collections</span>[% END %]
44
[% IF facets_loo.type_label_CollectionCodes %]<span id="facet-collections">Collections</span>[% END %]
45
[% IF facets_loo.type_label_Language %]<span id="facet-languages">Languages</span>[% END %]
45
[% IF facets_loo.type_label_Language %]<span id="facet-languages">Languages</span>[% END %]
46
[% IF facets_loo.type_label_HasEresource %]<span id="facet-has-eresource">E-resource</span>
47
  [%- FOREACH facet IN facets_loo.facets %]
48
    [% facet.facet_label_value = BLOCK %]
49
      [%- IF facet.facet_link_value == 'true' -%]
50
        <p>Digitally available</p>
51
      [%- ELSE -%]
52
        <p>Only in print</p>
53
      [%- END %]
54
    [% END %]
55
    [% facet.facet_label_value = facet.facet_label_value | remove('</?p>') %]
56
  [% END %]
57
[% END %]
46
<ul>
58
<ul>
47
  [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
59
  [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
48
  [% IF ( sort_by ) %]
60
  [% IF ( sort_by ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (+2 lines)
Lines 460-465 a.add, a.delete { Link Here
460
                                                    [% CASE 'holdingbranch' %]<span>Holding libraries</span>
460
                                                    [% CASE 'holdingbranch' %]<span>Holding libraries</span>
461
                                                    [% CASE 'homebranch' %]<span>Home libraries</span>
461
                                                    [% CASE 'homebranch' %]<span>Home libraries</span>
462
                                                    [% CASE 'ln' %]<span>Language</span>
462
                                                    [% CASE 'ln' %]<span>Language</span>
463
                                                    [% CASE 'has-eresource' %]<span>Has eresource</span>
464
                                                    [% CASE 'only-print' %]<span>Only print</span>
463
                                                    [% CASE %][% f | html %]
465
                                                    [% CASE %][% f | html %]
464
                                                    [% END %]
466
                                                    [% END %]
465
                                                </td>
467
                                                </td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc (-1 / +12 lines)
Lines 46-51 Link Here
46
                        [% IF facets_loo.type_label_ItemTypes %]<h3 id="facet-itemtypes">Item types</h3>[% END %]
46
                        [% IF facets_loo.type_label_ItemTypes %]<h3 id="facet-itemtypes">Item types</h3>[% END %]
47
                        [% IF facets_loo.type_label_CollectionCodes %]<h3 id="facet-collections">Collections</h3>[% END %]
47
                        [% IF facets_loo.type_label_CollectionCodes %]<h3 id="facet-collections">Collections</h3>[% END %]
48
                        [% IF facets_loo.type_label_Language %]<h3 id="facet-languages">Languages</h3>[% END %]
48
                        [% IF facets_loo.type_label_Language %]<h3 id="facet-languages">Languages</h3>[% END %]
49
                        [% IF facets_loo.type_label_HasEresource %]<h3 id="facet-has-eresource">E-resource</h3>
50
                           [%- FOREACH facet IN facets_loo.facets %]
51
                              [% facet.facet_label_value = BLOCK %]
52
                                [%- IF facet.facet_link_value == 'true' -%]
53
                                  <p>Digitally available</p>
54
                                [%- ELSE -%]
55
                                  <p>Only in print</p>
56
                                [%- END -%]
57
                              [% END %]
58
                              [% facet.facet_label_value = facet.facet_label_value | remove('</?p>') %]
59
                           [% END %]
60
                        [% END %]
49
                        [% UNLESS singleBranchMode %]
61
                        [% UNLESS singleBranchMode %]
50
                            [% IF ( facets_loo.type_label_HomeLibrary ) %]<h3 id="facet-home-libraries">Home libraries</h3>[% END %]
62
                            [% IF ( facets_loo.type_label_HomeLibrary ) %]<h3 id="facet-home-libraries">Home libraries</h3>[% END %]
51
                            [% IF ( facets_loo.type_label_HoldingLibrary ) %]<h3 id="facet-holding-libraries">Holding libraries</h3>[% END %]
63
                            [% IF ( facets_loo.type_label_HoldingLibrary ) %]<h3 id="facet-holding-libraries">Holding libraries</h3>[% END %]
52
- 

Return to bug 33139