Bugzilla – Attachment 43148 Details for
Bug 12478
Elasticsearch support for Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12478: Take the FacetMaxCount pref into account
Bug-12478-Take-the-FacetMaxCount-pref-into-account.patch (text/plain), 4.01 KB, created by
Jonathan Druart
on 2015-10-05 16:16:40 UTC
(
hide
)
Description:
Bug 12478: Take the FacetMaxCount pref into account
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-05 16:16:40 UTC
Size:
4.01 KB
patch
obsolete
>From 2294527d5c442fec8c475a3577f4fc64f8c1a1ba Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 5 Oct 2015 17:15:01 +0100 >Subject: [PATCH] Bug 12478: Take the FacetMaxCount pref into account > >The system preference FacetMaxCount should work as expected with ES. >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 7 ++++++- > Koha/SearchEngine/Elasticsearch/Search.pm | 5 +++-- > opac/opac-search.pl | 2 +- > 3 files changed, 10 insertions(+), 4 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 30bf6f8..67d06ba 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -46,6 +46,7 @@ use List::MoreUtils qw/ each_array /; > use Modern::Perl; > use URI::Escape; > >+use C4::Context; > use Data::Dumper; # TODO remove > > =head2 build_query >@@ -118,6 +119,9 @@ sub 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; > } > >@@ -181,7 +185,7 @@ reproduce this search, and C<$query_desc> set to something else. > > 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 ); >@@ -215,6 +219,7 @@ sub build_query_compat { > $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); >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index d7ce445..61d6491 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -148,6 +148,7 @@ sub search_compat { > > 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 >@@ -378,7 +379,7 @@ Converts elasticsearch facets types to the form that Koha expects. > 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 >@@ -415,7 +416,7 @@ sub _convert_facets { > 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, >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 13fbcab..4cfabec 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -505,7 +505,7 @@ my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ > my @results; > > ## I. BUILD THE QUERY >-( $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); >+( $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 }); > #die Dumper( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type); > > sub _input_cgi_parse { >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12478
:
29204
|
31128
|
31129
|
33136
|
33137
|
33138
|
33139
|
33140
|
33141
|
35654
|
40903
|
42030
|
42031
|
42032
|
42033
|
42062
|
42063
|
42064
|
42065
|
42066
|
42067
|
42068
|
42069
|
42392
|
42393
|
43127
|
43128
|
43129
|
43130
|
43131
|
43132
|
43133
|
43134
|
43140
|
43141
|
43142
|
43148
|
43345
|
43346
|
43347
|
43348
|
43349
|
43350
|
43351
|
43352
|
43373
|
47767
|
47768
|
50115
|
50159
|
50211
|
50212
|
50213
|
50214
|
50245
|
50246
|
50291
|
50292