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 226-252
sub build_query {
Link Here
|
226 |
# See _convert_facets in Search.pm for how these get turned into |
227 |
# See _convert_facets in Search.pm for how these get turned into |
227 |
# things that Koha can use. |
228 |
# things that Koha can use. |
228 |
my $size = C4::Context->preference('FacetMaxCount'); |
229 |
my $size = C4::Context->preference('FacetMaxCount'); |
229 |
$res->{aggregations} = { |
230 |
my @facets = Koha::SearchEngine::Elasticsearch->get_facet_fields; |
230 |
author => { terms => { field => "author__facet" , size => $size } }, |
231 |
for my $f ( @facets ) { |
231 |
subject => { terms => { field => "subject__facet", size => $size } }, |
232 |
my $name = $f->name; |
232 |
itype => { terms => { field => "itype__facet", size => $size} }, |
233 |
$res->{aggregations}->{$name} = { terms => { field => "${name}__facet" , size => $size } }; |
233 |
location => { terms => { field => "location__facet", size => $size } }, |
|
|
234 |
'su-geo' => { terms => { field => "su-geo__facet", size => $size} }, |
235 |
'title-series' => { terms => { field => "title-series__facet", size => $size } }, |
236 |
ccode => { terms => { field => "ccode__facet", size => $size } }, |
237 |
ln => { terms => { field => "ln__facet", size => $size } }, |
238 |
}; |
234 |
}; |
239 |
|
235 |
|
240 |
my $display_library_facets = C4::Context->preference('DisplayLibraryFacets'); |
|
|
241 |
if ( $display_library_facets eq 'both' |
242 |
or $display_library_facets eq 'home' ) { |
243 |
$res->{aggregations}{homebranch} = { terms => { field => "homebranch__facet", size => $size } }; |
244 |
} |
245 |
if ( $display_library_facets eq 'both' |
246 |
or $display_library_facets eq 'holding' ) { |
247 |
$res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } }; |
248 |
} |
249 |
|
236 |
|
|
|
237 |
# FIXME We need a way to show/hide the facet individually |
238 |
#my $display_library_facets = C4::Context->preference('DisplayLibraryFacets'); |
239 |
#if ( $display_library_facets eq 'both' |
240 |
# or $display_library_facets eq 'home' ) { |
241 |
# $res->{aggregations}{homebranch} = { terms => { field => "homebranch__facet", size => $size } }; |
242 |
#} |
243 |
#if ( $display_library_facets eq 'both' |
244 |
# or $display_library_facets eq 'holding' ) { |
245 |
# $res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet", size => $size } }; |
246 |
#} |
250 |
$res = _rebuild_to_es_advanced_query($res) if @$es_advanced_searches ; |
247 |
$res = _rebuild_to_es_advanced_query($res) if @$es_advanced_searches ; |
251 |
return $res; |
248 |
return $res; |
252 |
} |
249 |
} |