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

(-)a/C4/Search.pm (+1 lines)
Lines 579-584 sub getRecords { Link Here
579
                            "type_label_"
579
                            "type_label_"
580
                              . $facets_info->{$link_value}->{'label_value'} =>
580
                              . $facets_info->{$link_value}->{'label_value'} =>
581
                              1,
581
                              1,
582
                            label      => $facets_info->{$link_value}->{'label_value'},
582
                            facets     => \@this_facets_array,
583
                            facets     => \@this_facets_array,
583
                          }
584
                          }
584
                          unless (
585
                          unless (
(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +3 lines)
Lines 28-33 use Koha::Filter::MARC::EmbedSeeFromHeadings; Link Here
28
use Koha::SearchFields;
28
use Koha::SearchFields;
29
use Koha::SearchMarcMaps;
29
use Koha::SearchMarcMaps;
30
use Koha::Caches;
30
use Koha::Caches;
31
use Koha::AuthorisedValueCategories;
31
use C4::Heading;
32
use C4::Heading;
32
use C4::AuthoritiesMarc qw( GuessAuthTypeCode );
33
use C4::AuthoritiesMarc qw( GuessAuthTypeCode );
33
use C4::Biblio;
34
use C4::Biblio;
Lines 1404-1410 sub get_facetable_fields { Link Here
1404
1405
1405
    # These should correspond to the ES field names, as opposed to the CCL
1406
    # These should correspond to the ES field names, as opposed to the CCL
1406
    # things that zebra uses.
1407
    # things that zebra uses.
1407
    my @search_field_names = qw( author itype location su-geo title-series subject ccode holdingbranch homebranch ln );
1408
    #my @search_field_names = qw( author itype location su-geo title-series subject ccode holdingbranch homebranch ln );
1409
    my @search_field_names = Koha::AuthorisedValueCategories->find('ES_FACETS')->authorised_values->get_column('authorised_value');
1408
    my @faceted_fields = Koha::SearchFields->search(
1410
    my @faceted_fields = Koha::SearchFields->search(
1409
        { name => { -in => \@search_field_names }, facet_order => { '!=' => undef } }, { order_by => ['facet_order'] }
1411
        { name => { -in => \@search_field_names }, facet_order => { '!=' => undef } }, { order_by => ['facet_order'] }
1410
    )->as_list;
1412
    )->as_list;
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-18 / +15 lines)
Lines 48-53 use URI::Escape qw( uri_escape_utf8 ); Link Here
48
use C4::Context;
48
use C4::Context;
49
use Koha::Exceptions;
49
use Koha::Exceptions;
50
use Koha::Caches;
50
use Koha::Caches;
51
use Koha::AuthorisedValueCategories;
51
52
52
our %index_field_convert = (
53
our %index_field_convert = (
53
    'kw' => '',
54
    'kw' => '',
Lines 225-250 sub build_query { Link Here
225
    # See _convert_facets in Search.pm for how these get turned into
226
    # See _convert_facets in Search.pm for how these get turned into
226
    # things that Koha can use.
227
    # things that Koha can use.
227
    my $size = C4::Context->preference('FacetMaxCount');
228
    my $size = C4::Context->preference('FacetMaxCount');
228
    $res->{aggregations} = {
229
    my @facets = Koha::AuthorisedValueCategories->find('ES_FACETS')->authorised_values->as_list;
229
        author         => { terms => { field => "author__facet" , size => $size } },
230
    for my $f ( @facets ) {
230
        subject        => { terms => { field => "subject__facet", size => $size } },
231
        my $ff = $f->authorised_value;
231
        itype          => { terms => { field => "itype__facet", size => $size} },
232
        $res->{aggregations}->{$ff} = { terms => { field => "${ff}__facet" , size => $size } };
232
        location       => { terms => { field => "location__facet", size => $size } },
233
        'su-geo'       => { terms => { field => "su-geo__facet", size => $size} },
234
        'title-series' => { terms => { field => "title-series__facet", size => $size } },
235
        ccode          => { terms => { field => "ccode__facet", size => $size } },
236
        ln             => { terms => { field => "ln__facet", size => $size } },
237
    };
233
    };
238
234
239
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
235
    # FIXME We need a way to show/hide the facet individually
240
    if (   $display_library_facets eq 'both'
236
    #my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
241
        or $display_library_facets eq 'home' ) {
237
    #if (   $display_library_facets eq 'both'
242
        $res->{aggregations}{homebranch} = { terms => { field => "homebranch__facet", size => $size } };
238
    #    or $display_library_facets eq 'home' ) {
243
    }
239
    #    $res->{aggregations}{homebranch} = { terms => { field => "homebranch__facet", size => $size } };
244
    if (   $display_library_facets eq 'both'
240
    #}
245
        or $display_library_facets eq 'holding' ) {
241
    #if (   $display_library_facets eq 'both'
246
        $res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } };
242
    #    or $display_library_facets eq 'holding' ) {
247
    }
243
    #    $res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } };
244
    #}
248
    return $res;
245
    return $res;
249
}
246
}
250
247
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-12 / +15 lines)
Lines 45-50 use C4::Context; Link Here
45
use C4::AuthoritiesMarc;
45
use C4::AuthoritiesMarc;
46
use Koha::ItemTypes;
46
use Koha::ItemTypes;
47
use Koha::AuthorisedValues;
47
use Koha::AuthorisedValues;
48
use Koha::AuthorisedValueCategories;
48
use Koha::SearchEngine::QueryBuilder;
49
use Koha::SearchEngine::QueryBuilder;
49
use Koha::SearchEngine::Search;
50
use Koha::SearchEngine::Search;
50
use Koha::Exceptions::Elasticsearch;
51
use Koha::Exceptions::Elasticsearch;
Lines 443-460 sub _convert_facets { Link Here
443
    # These should correspond to the ES field names, as opposed to the CCL
444
    # These should correspond to the ES field names, as opposed to the CCL
444
    # things that zebra uses.
445
    # things that zebra uses.
445
    my %type_to_label;
446
    my %type_to_label;
446
    my %label = (
447
    #my %label = (
447
        author         => 'Authors',
448
    #    author         => 'Authors',
448
        itype          => 'ItemTypes',
449
    #    itype          => 'ItemTypes',
449
        location       => 'Location',
450
    #    location       => 'Location',
450
        'su-geo'       => 'Places',
451
    #    'su-geo'       => 'Places',
451
        'title-series' => 'Series',
452
    #    'title-series' => 'Series',
452
        subject        => 'Topics',
453
    #    subject        => 'Topics',
453
        ccode          => 'CollectionCodes',
454
    #    ccode          => 'CollectionCodes',
454
        holdingbranch  => 'HoldingLibrary',
455
    #    holdingbranch  => 'HoldingLibrary',
455
        homebranch     => 'HomeLibrary',
456
    #    homebranch     => 'HomeLibrary',
456
        ln             => 'Language',
457
    #    ln             => 'Language',
457
    );
458
    #);
459
    my %label = map {$_->authorised_value => $_->lib } Koha::AuthorisedValueCategories->find('ES_FACETS')->authorised_values->as_list;
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
    for my $f (@facetable_fields) {
Lines 486-491 sub _convert_facets { Link Here
486
        my $facet = {
488
        my $facet = {
487
            type_id    => $type . '_id',
489
            type_id    => $type . '_id',
488
            "type_label_$type_to_label{$type}{label}" => 1,
490
            "type_label_$type_to_label{$type}{label}" => 1,
491
            label => $type_to_label{$type}{label},
489
            type_link_value                    => $type,
492
            type_link_value                    => $type,
490
            order      => $type_to_label{$type}{order},
493
            order      => $type_to_label{$type}{order},
491
        };
494
        };
(-)a/installer/data/mysql/atomicupdate/bug_35138.pl (+30 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "35138",
5
    description => "Add ES_FACETS AV cat",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{INSERT IGNORE INTO authorised_value_categories(category_name, is_system) VALUES('ES_FACETS', 1)});
11
        my $sth = $dbh->prepare(
12
            q{INSERT IGNORE INTO authorised_values(category, authorised_value, lib) VALUES('ES_FACETS', ?, ?)});
13
14
        my $facets = {
15
            author         => 'Authors',
16
            itype          => 'ItemTypes',
17
            location       => 'Location',
18
            'su-geo'       => 'Places',
19
            'title-series' => 'Series',
20
            subject        => 'Topics',
21
            ccode          => 'CollectionCodes',
22
            holdingbranch  => 'HoldingLibrary',
23
            homebranch     => 'HomeLibrary',
24
            ln             => 'Language',
25
        };
26
        while ( my ( $av, $lib ) = each %$facets ) {
27
            $sth->execute( $av, $lib );
28
        }
29
    },
30
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (-22 / +14 lines)
Lines 51-88 Link Here
51
                    [% IF facets_loo.facets.size > 0 %]
51
                    [% IF facets_loo.facets.size > 0 %]
52
                        <li id="[% facets_loo.type_id | html %]">
52
                        <li id="[% facets_loo.type_id | html %]">
53
                            [% facets_loo.type_label | html %]
53
                            [% facets_loo.type_label | html %]
54
                            [% IF facets_loo.type_label_Authors %]
54
                            [% SWITCH facets_loo.label %]
55
                            [% CASE 'Authors' %]
55
                                <span id="facet-authors">Authors</span>
56
                                <span id="facet-authors">Authors</span>
56
                            [% END %]
57
                            [% CASE 'Titles' %]
57
                            [% IF facets_loo.type_label_Titles %]
58
                                <span id="facet-titles">Titles</span>
58
                                <span id="facet-titles">Titles</span>
59
                            [% END %]
59
                            [% CASE 'Topics' %]
60
                            [% IF facets_loo.type_label_Topics %]
61
                                <span id="facet-topics">Topics</span>
60
                                <span id="facet-topics">Topics</span>
62
                            [% END %]
61
                            [% CASE 'Places' %]
63
                            [% IF facets_loo.type_label_Places %]
64
                                <span id="facet-places">Places</span>
62
                                <span id="facet-places">Places</span>
65
                            [% END %]
63
                            [% CASE 'Series' %]
66
                            [% IF facets_loo.type_label_Series %]
67
                                <span id="facet-series">Series</span>
64
                                <span id="facet-series">Series</span>
68
                            [% END %]
65
                            [% CASE 'ItemTypes' %]
69
                            [% IF facets_loo.type_label_ItemTypes %]
70
                                <span id="facet-itemtypes">Item types</span>
66
                                <span id="facet-itemtypes">Item types</span>
71
                            [% END %]
67
                            [% CASE 'HomeLibrary' %]
72
                            [% IF ( facets_loo.type_label_HomeLibrary ) %]
73
                                <span id="facet-home-libraries">Home libraries</span>
68
                                <span id="facet-home-libraries">Home libraries</span>
74
                            [% END %]
69
                            [% CASE 'HoldingLibrary' %]
75
                            [% IF ( facets_loo.type_label_HoldingLibrary ) %]
76
                                <span id="facet-holding-libraries">Holding libraries</span>
70
                                <span id="facet-holding-libraries">Holding libraries</span>
77
                            [% END %]
71
                            [% CASE 'Location' %]
78
                            [% IF facets_loo.type_label_Location %]
79
                                <span id="facet-locations">Locations</span>
72
                                <span id="facet-locations">Locations</span>
80
                            [% END %]
73
                            [% CASE 'CollectionCodes' %]
81
                            [% IF facets_loo.type_label_CollectionCodes %]
82
                                <span id="facet-collections">Collections</span>
74
                                <span id="facet-collections">Collections</span>
83
                            [% END %]
75
                            [% CASE 'Languages' %]
84
                            [% IF facets_loo.type_label_Language %]
85
                                <span id="facet-languages">Languages</span>
76
                                <span id="facet-languages">Languages</span>
77
                            [% CASE %]
78
                                <span id="facet-[% facets_loo.type_link_value | html %]">[% facets_loo.label | html %]</span>
86
                            [% END %]
79
                            [% END %]
87
                            <ul>
80
                            <ul>
88
                                [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
81
                                [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
89
- 

Return to bug 35138