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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +6 lines)
Lines 46-51 use List::MoreUtils qw/ each_array /; Link Here
46
use Modern::Perl;
46
use Modern::Perl;
47
use URI::Escape;
47
use URI::Escape;
48
48
49
use C4::Context;
49
use Data::Dumper;    # TODO remove
50
use Data::Dumper;    # TODO remove
50
51
51
=head2 build_query
52
=head2 build_query
Lines 118-123 sub build_query { Link Here
118
        'su-geo' => { terms => { field => "su-geo__facet" } },
119
        'su-geo' => { terms => { field => "su-geo__facet" } },
119
        se       => { terms => { field => "se__facet" } },
120
        se       => { terms => { field => "se__facet" } },
120
    };
121
    };
122
    if ( my $ef = $options{expanded_facet} ) {
123
        $res->{facets}{$ef}{terms}{size} = C4::Context->preference('FacetMaxCount');
124
    };
121
    return $res;
125
    return $res;
122
}
126
}
123
127
Lines 181-187 reproduce this search, and C<$query_desc> set to something else. Link Here
181
185
182
sub build_query_compat {
186
sub build_query_compat {
183
    my ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan,
187
    my ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan,
184
        $lang )
188
        $lang, $params )
185
      = @_;
189
      = @_;
186
190
187
#die Dumper ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan, $lang );
191
#die Dumper ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan, $lang );
Lines 215-220 sub build_query_compat { Link Here
215
    $query_str =~ s/^ AND //;
219
    $query_str =~ s/^ AND //;
216
    my %options;
220
    my %options;
217
    $options{sort} = \@sort_params;
221
    $options{sort} = \@sort_params;
222
    $options{expanded_facet} = $params->{expanded_facet};
218
    my $query = $self->build_query( $query_str, %options );
223
    my $query = $self->build_query( $query_str, %options );
219
224
220
    #die Dumper($query);
225
    #die Dumper($query);
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-2 / +3 lines)
Lines 148-153 sub search_compat { Link Here
148
148
149
    my %options;
149
    my %options;
150
    $options{offset} = $offset;
150
    $options{offset} = $offset;
151
    $options{expanded_facet} = $expanded_facet;
151
    my $results = $self->search($query, undef, $results_per_page, %options);
152
    my $results = $self->search($query, undef, $results_per_page, %options);
152
153
153
    # Convert each result into a MARC::Record
154
    # Convert each result into a MARC::Record
Lines 378-384 Converts elasticsearch facets types to the form that Koha expects. Link Here
378
It expects the ES facet name to match the Koha type, for example C<itype>,
379
It expects the ES facet name to match the Koha type, for example C<itype>,
379
C<au>, C<su-to>, etc.
380
C<au>, C<su-to>, etc.
380
381
381
C<$expanded_facet> is the facet that we want to show 10 entries for, rather
382
C<$expanded_facet> is the facet that we want to show FacetMaxCount entries for, rather
382
than just 5 like normal.
383
than just 5 like normal.
383
384
384
=cut
385
=cut
Lines 415-421 sub _convert_facets { Link Here
415
        next if !exists( $type_to_label{$type} );
416
        next if !exists( $type_to_label{$type} );
416
417
417
        # We restrict to the most popular $limit !results
418
        # We restrict to the most popular $limit !results
418
        my $limit = ( $type eq $exp_facet ) ? 10 : 5;
419
        my $limit = ( $type eq $exp_facet ) ? C4::Context->preference('FacetMaxCount') : 5;
419
        my $facet = {
420
        my $facet = {
420
            type_id    => $type . '_id',
421
            type_id    => $type . '_id',
421
            expand     => $type,
422
            expand     => $type,
(-)a/opac/opac-search.pl (-2 / +1 lines)
Lines 505-511 my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ Link Here
505
my @results;
505
my @results;
506
506
507
## I. BUILD THE QUERY
507
## I. BUILD THE QUERY
508
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = $builder->build_query_compat(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
508
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = $builder->build_query_compat(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang, { expanded_facet => $expanded_facet });
509
#die Dumper( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
509
#die Dumper( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
510
510
511
sub _input_cgi_parse {
511
sub _input_cgi_parse {
512
- 

Return to bug 12478