The system preference FacetMaxCount should work as expected with ES.
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
use Modern::Perl;
use URI::Escape;
+use C4::Context;
use Data::Dumper; # TODO remove
=head2 build_query
'su-geo' => { terms => { field => "su-geo__facet" } },
se => { terms => { field => "se__facet" } },
};
+ if ( my $ef = $options{expanded_facet} ) {
+ $res->{facets}{$ef}{terms}{size} = C4::Context->preference('FacetMaxCount');
+ };
return $res;
}
sub build_query_compat {
my ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan,
- $lang )
+ $lang, $params )
= @_;
#die Dumper ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan, $lang );
$query_str =~ s/^ AND //;
my %options;
$options{sort} = \@sort_params;
+ $options{expanded_facet} = $params->{expanded_facet};
my $query = $self->build_query( $query_str, %options );
#die Dumper($query);
my %options;
$options{offset} = $offset;
+ $options{expanded_facet} = $expanded_facet;
my $results = $self->search($query, undef, $results_per_page, %options);
# Convert each result into a MARC::Record
It expects the ES facet name to match the Koha type, for example C<itype>,
C<au>, C<su-to>, etc.
-C<$expanded_facet> is the facet that we want to show 10 entries for, rather
+C<$expanded_facet> is the facet that we want to show FacetMaxCount entries for, rather
than just 5 like normal.
=cut
next if !exists( $type_to_label{$type} );
# We restrict to the most popular $limit !results
- my $limit = ( $type eq $exp_facet ) ? 10 : 5;
+ my $limit = ( $type eq $exp_facet ) ? C4::Context->preference('FacetMaxCount') : 5;
my $facet = {
type_id => $type . '_id',
expand => $type,
my @results;
## I. BUILD THE QUERY
-( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = $builder->build_query_compat(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
+( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = $builder->build_query_compat(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang, { expanded_facet => $expanded_facet });
sub _input_cgi_parse {
my @elements;