Lines 145-159
get ignored here, along with some other things (like C<@servers>.)
Link Here
|
145 |
sub search_compat { |
145 |
sub search_compat { |
146 |
my ( |
146 |
my ( |
147 |
$self, $query, $simple_query, $sort_by, |
147 |
$self, $query, $simple_query, $sort_by, |
148 |
$servers, $results_per_page, $offset, $expanded_facet, |
148 |
$servers, $results_per_page, $offset, |
149 |
$branches, $query_type, $scan |
149 |
$branches, $query_type, $scan |
150 |
) = @_; |
150 |
) = @_; |
151 |
my %options; |
151 |
my %options; |
152 |
if ( !defined $offset or $offset < 0 ) { |
152 |
if ( !defined $offset or $offset < 0 ) { |
153 |
$offset = 0; |
153 |
$offset = 0; |
154 |
} |
154 |
} |
|
|
155 |
|
155 |
$options{offset} = $offset; |
156 |
$options{offset} = $offset; |
156 |
$options{expanded_facet} = $expanded_facet; |
|
|
157 |
my $results = $self->search($query, undef, $results_per_page, %options); |
157 |
my $results = $self->search($query, undef, $results_per_page, %options); |
158 |
|
158 |
|
159 |
# Convert each result into a MARC::Record |
159 |
# Convert each result into a MARC::Record |
Lines 171-177
sub search_compat {
Link Here
|
171 |
my %result; |
171 |
my %result; |
172 |
$result{biblioserver}{hits} = $hits->{'total'}; |
172 |
$result{biblioserver}{hits} = $hits->{'total'}; |
173 |
$result{biblioserver}{RECORDS} = \@records; |
173 |
$result{biblioserver}{RECORDS} = \@records; |
174 |
return (undef, \%result, $self->_convert_facets($results->{aggregations}, $expanded_facet)); |
174 |
return (undef, \%result, $self->_convert_facets($results->{aggregations})); |
175 |
} |
175 |
} |
176 |
|
176 |
|
177 |
=head2 search_auth_compat |
177 |
=head2 search_auth_compat |
Lines 430-436
than just 5 like normal.
Link Here
|
430 |
=cut |
430 |
=cut |
431 |
|
431 |
|
432 |
sub _convert_facets { |
432 |
sub _convert_facets { |
433 |
my ( $self, $es, $exp_facet ) = @_; |
433 |
my ( $self, $es) = @_; |
434 |
|
434 |
|
435 |
return if !$es; |
435 |
return if !$es; |
436 |
|
436 |
|
Lines 471-487
sub _convert_facets {
Link Here
|
471 |
homebranch => $library_names |
471 |
homebranch => $library_names |
472 |
); |
472 |
); |
473 |
my @facets; |
473 |
my @facets; |
474 |
$exp_facet //= ''; |
|
|
475 |
while ( my ( $type, $data ) = each %$es ) { |
474 |
while ( my ( $type, $data ) = each %$es ) { |
476 |
next if !exists( $type_to_label{$type} ); |
475 |
next if !exists( $type_to_label{$type} ); |
477 |
|
476 |
|
478 |
# We restrict to the most popular $limit !results |
477 |
# We restrict to the most popular $limit !results |
479 |
my $limit = ( $type eq $exp_facet ) ? C4::Context->preference('FacetMaxCount') : 5; |
478 |
my $limit = C4::Context->preference('FacetMaxCount') || 5 ; |
480 |
my $facet = { |
479 |
my $facet = { |
481 |
type_id => $type . '_id', |
480 |
type_id => $type . '_id', |
482 |
expand => $type, |
481 |
expand => $type, |
483 |
expandable => ( $type ne $exp_facet ) |
|
|
484 |
&& ( @{ $data->{buckets} } > $limit ), |
485 |
"type_label_$type_to_label{$type}{label}" => 1, |
482 |
"type_label_$type_to_label{$type}{label}" => 1, |
486 |
type_link_value => $type, |
483 |
type_link_value => $type, |
487 |
order => $type_to_label{$type}{order}, |
484 |
order => $type_to_label{$type}{order}, |