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 |
|