Bugzilla – Attachment 96355 Details for
Bug 14419
Expanding facets (Show more) performs a new search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14419: [19.05.x] (squashed) Expanding facets (Show more) performs a new search
Bug-14419-1905x-squashed-Expanding-facets-Show-mor.patch (text/plain), 61.92 KB, created by
Nick Clemens (kidclamp)
on 2019-12-17 01:31:32 UTC
(
hide
)
Description:
Bug 14419: [19.05.x] (squashed) Expanding facets (Show more) performs a new search
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-12-17 01:31:32 UTC
Size:
61.92 KB
patch
obsolete
>From 39e1e0a42b9e25c83f456251b0885240903682b2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 2 Jul 2019 11:58:49 +0000 >Subject: [PATCH] Bug 14419: [19.05.x] (squashed) Expanding facets (Show more) > performs a new search > >This patch removes the constraint of only passing 5 facets to the template unless the list is expanded, in fact, it removes the 'expanded' attribute from Search.pm >Now that all facets are passed to page it adds a 'show more' link at the bottom of lists and allows user to expand or collapse any facet set without reloading page. > >Updated tests included. > >To test: >1 - Perform an OPAC search that returns more than 5 of any given facet type >2 - Click the "Show more" link on the facets and see that the search is reloaded >3 - Apply patch >4 - Repeat search >5 - Note that you can click "Show more" without reloading page >6 - Test that page load is not greatly affected >7 - Ensure that all facet links function normally >8 - Ensure that facets are the same a prior to patch >9 - Repeat for staff client >10 - Prove t/Search.t > >NOTE: This patch makes it much easier to see that there is an existing issue with marking the "active" facet. Ending punctuation seems to confuse the matcher. > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Bug 14419: (QA follow-up) Restore the link styling > >Test plan: >Look at Show more/less links in facets, in opac and staff client >--> without this patch they are pure text, no styling, no hand cursor >--> with this patch it is link, but continues to work as before > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Search.pm | 161 +++++++++------------ > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 21 ++- > Koha/SearchEngine/Elasticsearch/Search.pm | 21 +-- > catalogue/search.pl | 5 +- > .../intranet-tmpl/prog/en/includes/facets.inc | 13 +- > .../prog/en/modules/catalogue/results.tt | 8 + > .../bootstrap/en/includes/opac-facets.inc | 13 +- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 8 + > opac/opac-detail.pl | 3 +- > opac/opac-search.pl | 6 +- > .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 7 +- > t/db_dependent/Search.t | 133 ++++++++--------- > 12 files changed, 192 insertions(+), 207 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 09ad5e1430..fe8898fed6 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -312,22 +312,22 @@ sub SimpleSearch { > ( undef, $results_hashref, \@facets_loop ) = getRecords ( > > $koha_query, $simple_query, $sort_by_ref, $servers_ref, >- $results_per_page, $offset, $expanded_facet, $branches,$itemtypes, >- $query_type, $scan >+ $results_per_page, $offset, $branches, $itemtypes, >+ $query_type, $scan, $opac > ); > > The all singing, all dancing, multi-server, asynchronous, scanning, > searching, record nabbing, facet-building > >-See verbse embedded documentation. >+See verbose embedded documentation. > > =cut > > sub getRecords { > my ( > $koha_query, $simple_query, $sort_by_ref, $servers_ref, >- $results_per_page, $offset, $expanded_facet, $branches, >- $itemtypes, $query_type, $scan, $opac >+ $results_per_page, $offset, $branches, $itemtypes, >+ $query_type, $scan, $opac > ) = @_; > > my @servers = @$servers_ref; >@@ -516,8 +516,6 @@ sub getRecords { > keys %$facets_counter > ) > { >- my $expandable; >- my $number_of_facets; > my @this_facets_array; > for my $one_facet ( > sort { >@@ -527,94 +525,80 @@ sub getRecords { > } keys %{ $facets_counter->{$link_value} } > ) > { >- $number_of_facets++; >- if ( ( $number_of_facets <= 5 ) >- || ( $expanded_facet eq $link_value ) >- || ( $facets_info->{$link_value}->{'expanded'} ) >- ) >- { >- > # Sanitize the link value : parenthesis, question and exclamation mark will cause errors with CCL >- my $facet_link_value = $one_facet; >- $facet_link_value =~ s/[()!?¡¿Ø]/ /g; >- >- # fix the length that will display in the label, >- my $facet_label_value = $one_facet; >- my $facet_max_length = C4::Context->preference( >- 'FacetLabelTruncationLength') >- || 20; >- $facet_label_value = >- substr( $one_facet, 0, $facet_max_length ) >- . "..." >- if length($facet_label_value) > >- $facet_max_length; >- >- # if it's a branch, label by the name, not the code, >- if ( $link_value =~ /branch/ ) { >- if ( defined $branches >- && ref($branches) eq "HASH" >- && defined $branches->{$one_facet} >- && ref( $branches->{$one_facet} ) eq >- "HASH" ) >- { >- $facet_label_value = >- $branches->{$one_facet} >- ->{'branchname'}; >- } >- else { >- $facet_label_value = "*"; >- } >+ my $facet_link_value = $one_facet; >+ $facet_link_value =~ s/[()!?¡¿Ø]/ /g; >+ >+ # fix the length that will display in the label, >+ my $facet_label_value = $one_facet; >+ my $facet_max_length = C4::Context->preference( >+ 'FacetLabelTruncationLength') >+ || 20; >+ $facet_label_value = >+ substr( $one_facet, 0, $facet_max_length ) >+ . "..." >+ if length($facet_label_value) > >+ $facet_max_length; >+ >+ # if it's a branch, label by the name, not the code, >+ if ( $link_value =~ /branch/ ) { >+ if ( defined $branches >+ && ref($branches) eq "HASH" >+ && defined $branches->{$one_facet} >+ && ref( $branches->{$one_facet} ) eq >+ "HASH" ) >+ { >+ $facet_label_value = >+ $branches->{$one_facet} >+ ->{'branchname'}; > } >- >- # if it's a itemtype, label by the name, not the code, >- if ( $link_value =~ /itype/ ) { >- if ( defined $itemtypes >- && ref($itemtypes) eq "HASH" >- && defined $itemtypes->{$one_facet} >- && ref( $itemtypes->{$one_facet} ) eq >- "HASH" ) >- { >- $facet_label_value = >- $itemtypes->{$one_facet} >- ->{translated_description}; >- } >+ else { >+ $facet_label_value = "*"; > } >+ } > >- # also, if it's a location code, use the name instead of the code >- if ( $link_value =~ /location/ ) { >- # TODO Retrieve all authorised values at once, instead of 1 query per entry >- my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet }); >- $facet_label_value = $av->count ? $av->next->opac_description : ''; >+ # if it's a itemtype, label by the name, not the code, >+ if ( $link_value =~ /itype/ ) { >+ if ( defined $itemtypes >+ && ref($itemtypes) eq "HASH" >+ && defined $itemtypes->{$one_facet} >+ && ref( $itemtypes->{$one_facet} ) eq >+ "HASH" ) >+ { >+ $facet_label_value = >+ $itemtypes->{$one_facet} >+ ->{translated_description}; > } >+ } > >- # also, if it's a collection code, use the name instead of the code >- if ( $link_value =~ /ccode/ ) { >- # TODO Retrieve all authorised values at once, instead of 1 query per entry >- my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $one_facet }); >- $facet_label_value = $av->count ? $av->next->opac_description : ''; >- } >+ # also, if it's a location code, use the name instead of the code >+ if ( $link_value =~ /location/ ) { >+ # TODO Retrieve all authorised values at once, instead of 1 query per entry >+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet }); >+ $facet_label_value = $av->count ? $av->next->opac_description : ''; >+ } > >- # but we're down with the whole label being in the link's title. >- push @this_facets_array, >- { >- facet_count => >- $facets_counter->{$link_value} >- ->{$one_facet}, >- facet_label_value => $facet_label_value, >- facet_title_value => $one_facet, >- facet_link_value => $facet_link_value, >- type_link_value => $link_value, >- } >- if ($facet_label_value); >+ # also, if it's a collection code, use the name instead of the code >+ if ( $link_value =~ /ccode/ ) { >+ # TODO Retrieve all authorised values at once, instead of 1 query per entry >+ my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $one_facet }); >+ $facet_label_value = $av->count ? $av->next->opac_description : ''; > } >- } > >- # handle expanded option >- unless ( $facets_info->{$link_value}->{'expanded'} ) { >- $expandable = 1 >- if ( ( $number_of_facets > 5 ) >- && ( $expanded_facet ne $link_value ) ); >+ # but we're down with the whole label being in the link's title. >+ push @this_facets_array, >+ { >+ facet_count => >+ $facets_counter->{$link_value} >+ ->{$one_facet}, >+ facet_label_value => $facet_label_value, >+ facet_title_value => $one_facet, >+ facet_link_value => $facet_link_value, >+ type_link_value => $link_value, >+ } >+ if ($facet_label_value); > } >+ > push @facets_loop, > { > type_link_value => $link_value, >@@ -623,8 +607,6 @@ sub getRecords { > . $facets_info->{$link_value}->{'label_value'} => > 1, > facets => \@this_facets_array, >- expandable => $expandable, >- expand => $link_value, > } > unless ( > ( >@@ -852,7 +834,6 @@ sub _get_facets_info { > > for my $facet ( @$facets ) { > $facets_info->{ $facet->{ idx } }->{ label_value } = $facet->{ label }; >- $facets_info->{ $facet->{ idx } }->{ expanded } = $facet->{ expanded }; > } > > return $facets_info; >@@ -861,8 +842,8 @@ sub _get_facets_info { > sub pazGetRecords { > my ( > $koha_query, $simple_query, $sort_by_ref, $servers_ref, >- $results_per_page, $offset, $expanded_facet, $branches, >- $query_type, $scan >+ $results_per_page, $offset, $branches, $query_type, >+ $scan > ) = @_; > #NOTE: Parameter $branches is not used here ! > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 63b9dbce7b..0478404fe0 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -111,15 +111,16 @@ sub build_query { > > # See _convert_facets in Search.pm for how these get turned into > # things that Koha can use. >+ my $size = C4::Context->preference('FacetMaxCount'); > $res->{aggregations} = { >- author => { terms => { field => "author__facet" } }, >- subject => { terms => { field => "subject__facet" } }, >- itype => { terms => { field => "itype__facet" } }, >- location => { terms => { field => "location__facet" } }, >- 'su-geo' => { terms => { field => "su-geo__facet" } }, >- 'title-series' => { terms => { field => "title-series__facet" } }, >- ccode => { terms => { field => "ccode__facet" } }, >- ln => { terms => { field => "ln__facet" } }, >+ author => { terms => { field => "author__facet" , size => $size } }, >+ subject => { terms => { field => "subject__facet", size => $size } }, >+ itype => { terms => { field => "itype__facet", size => $size} }, >+ location => { terms => { field => "location__facet", size => $size } }, >+ 'su-geo' => { terms => { field => "su-geo__facet", size => $size} }, >+ 'title-series' => { terms => { field => "title-series__facet", size => $size } }, >+ ccode => { terms => { field => "ccode__facet", size => $size } }, >+ ln => { terms => { field => "ln__facet", size => $size } }, > }; > > my $display_library_facets = C4::Context->preference('DisplayLibraryFacets'); >@@ -131,9 +132,6 @@ sub build_query { > or $display_library_facets eq 'holding' ) { > $res->{aggregations}{holdingbranch} = { terms => { field => "holdingbranch__facet" } }; > } >- if ( my $ef = $options{expanded_facet} ) { >- $res->{aggregations}{$ef}{terms}{size} = C4::Context->preference('FacetMaxCount'); >- }; > return $res; > } > >@@ -243,7 +241,6 @@ sub build_query_compat { > my %options; > $options{fields} = \@fields; > $options{sort} = \@sort_params; >- $options{expanded_facet} = $params->{expanded_facet}; > my $query = $self->build_query( $query_str, %options ); > > # We roughly emulate the CGI parameters of the zebra query builder >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index a4b4e84cae..f37252cb5d 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -132,8 +132,8 @@ sub count { > > my ( $error, $results, $facets ) = $search->search_compat( > $query, $simple_query, \@sort_by, \@servers, >- $results_per_page, $offset, $expanded_facet, $branches, >- $query_type, $scan >+ $results_per_page, $offset, $branches, $query_type, >+ $scan > ) > > A search interface somewhat compatible with L<C4::Search->getRecords>. Anything >@@ -145,15 +145,14 @@ get ignored here, along with some other things (like C<@servers>.) > sub search_compat { > my ( > $self, $query, $simple_query, $sort_by, >- $servers, $results_per_page, $offset, $expanded_facet, >- $branches, $query_type, $scan >+ $servers, $results_per_page, $offset, $branches, >+ $query_type, $scan > ) = @_; > my %options; > if ( !defined $offset or $offset < 0 ) { > $offset = 0; > } > $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 >@@ -171,7 +170,7 @@ sub search_compat { > my %result; > $result{biblioserver}{hits} = $hits->{'total'}; > $result{biblioserver}{RECORDS} = \@records; >- return (undef, \%result, $self->_convert_facets($results->{aggregations}, $expanded_facet)); >+ return (undef, \%result, $self->_convert_facets($results->{aggregations})); > } > > =head2 search_auth_compat >@@ -418,15 +417,12 @@ sub max_result_window { > > =head2 _convert_facets > >- my $koha_facets = _convert_facets($es_facets, $expanded_facet); >+ my $koha_facets = _convert_facets($es_facets); > > 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 FacetMaxCount entries for, rather >-than just 5 like normal. >- > =cut > > sub _convert_facets { >@@ -476,12 +472,9 @@ sub _convert_facets { > next if !exists( $type_to_label{$type} ); > > # We restrict to the most popular $limit !results >- my $limit = ( $type eq $exp_facet ) ? C4::Context->preference('FacetMaxCount') : 5; >+ my $limit = C4::Context->preference('FacetMaxCount'); > my $facet = { > type_id => $type . '_id', >- expand => $type, >- expandable => ( $type ne $exp_facet ) >- && ( @{ $data->{buckets} } > $limit ), > "type_label_$type_to_label{$type}{label}" => 1, > type_link_value => $type, > order => $type_to_label{$type}{order}, >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 514c4a9b2c..a3a7015efc 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -459,7 +459,6 @@ my $offset = $params->{'offset'} || 0; > $offset = 0 if $offset < 0; > my $page = $cgi->param('page') || 1; > #my $offset = ($page-1)*$results_per_page; >-my $expanded_facet = $params->{'expand'}; > > # Define some global variables > my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type); >@@ -536,8 +535,8 @@ eval { > my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; > ( $error, $results_hashref, $facets ) = $searcher->search_compat( > $query, $simple_query, \@sort_by, \@servers, >- $results_per_page, $offset, $expanded_facet, undef, >- $itemtypes, $query_type, $scan >+ $results_per_page, $offset, undef, $itemtypes, >+ $query_type, $scan > ); > }; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >index e67919c380..7b58d25839 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >@@ -33,7 +33,11 @@ > [% FOREACH facet IN facets_loo.facets %] > [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,0) || facet.facet_label_value %][% END %] > [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %] >+ [% IF loop.count > 5 && !facet.active %] >+ <li class="collapsible-facet" style="display:none"> >+ [% ELSE %] > <li> >+ [% END %] > [% IF facet.active %] > [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %] > <span class="facet-label">[% facet.facet_label_value | html %]</span> >@@ -47,9 +51,12 @@ > [% END %] > </li> > [% END %] >- [% IF ( facets_loo.expandable ) %] >- <li class="showmore"> >- <a href="[% url | $raw %][% IF offset %]&offset=[% offset | uri %][% END %]&expand=[% facets_loo.expand | uri %]#[% facets_loo.type_id | uri %]">Show more</a> >+ [% IF facets_loo.facets.size > 5 %] >+ <li class="moretoggle"> >+ <a href="#"><strong>Show more</strong></a> >+ </li> >+ <li class="moretoggle" style="display:none"> >+ <a href="#"><strong>Show less</strong></a> > </li> > [% END %] > </ul></li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 3e395867d7..54a04feab7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -667,6 +667,14 @@ > [% END %] > var Sticky; > $(document).ready(function() { >+ >+ $(".moretoggle").click(function(e) { >+ e.preventDefault(); >+ $(this).siblings(".collapsible-facet").toggle(); >+ $(this).siblings(".moretoggle").toggle(); >+ $(this).toggle(); >+ }); >+ > Sticky = $("#searchheader"); > Sticky.hcSticky({ > stickTo: "main", >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc >index 10ce6968aa..847ae0c211 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc >@@ -42,7 +42,11 @@ > [% FOREACH facet IN facets_loo.facets %] > [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,1) || facet.facet_label_value %][% END %] > [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %] >+ [% IF loop.count > 5 && !facet.active %] >+ <li class="collapsible-facet" style="display:none"> >+ [% ELSE %] > <li> >+ [% END %] > [% IF facet.active %] > [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %] > <span class="facet-label">[% facet.facet_label_value | html %]</span> >@@ -56,9 +60,12 @@ > [% END %] > </li> > [% END %] >- [% IF ( facets_loo.expandable ) %] >- <li class="showmore"> >- <a href="[% url | $raw %][% IF offset %]&offset=[% offset | uri %][% END %]&expand=[% facets_loo.expand | uri %]#[% facets_loo.type_id | uri %]">Show more</a> >+ [% IF facets_loo.facets.size > 5 %] >+ <li class="moretoggle"> >+ <a href="#"><strong>Show more</strong></a> >+ </li> >+ <li class="moretoggle" style="display:none"> >+ <a href="#"><strong>Show less</strong></a> > </li> > [% END %] > </ul> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 59b3766f4f..906709c3bc 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -737,6 +737,14 @@ function highlightOn() { > } > [% END %] > $(document).ready(function(){ >+ >+ $(".moretoggle").click(function(e){ >+ e.preventDefault(); >+ $(this).siblings(".collapsible-facet").toggle(); >+ $(this).siblings(".moretoggle").toggle(); >+ $(this).toggle(); >+ }); >+ > [% IF ( OpacHighlightedWords ) %] > $('a.title').each(function() { > $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]"); >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 82438e5854..e71afd67e3 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -224,7 +224,6 @@ if ($session->param('busc')) { > { > my ($arrParamsBusc, $offset, $results_per_page) = @_; > >- my $expanded_facet = $arrParamsBusc->{'expand'}; > my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; > my @servers; > @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'}; >@@ -236,7 +235,7 @@ if ($session->param('busc')) { > $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by); > my ($error, $results_hashref, $facets); > eval { >- ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'}); >+ ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'}); > }; > my $hits; > my @newresults; >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 9f18049e4b..a7351bb65d 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -535,7 +535,6 @@ $offset = 0 if $offset < 0; > my $page = $cgi->param('page') || 1; > $offset = ($page-1)*$results_per_page if $page>1; > my $hits; >-my $expanded_facet = $params->{'expand'}; > > # Define some global variables > my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type); >@@ -556,7 +555,6 @@ if (C4::Context->preference('OpacSuppression')) { > } > > my $build_params = { >- expanded_facet => $expanded_facet, > suppress => $suppress > }; > >@@ -622,7 +620,7 @@ if ($tag) { > # FIXME: No facets for tags search. > } elsif ($build_grouped_results) { > eval { >- ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan); >+ ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$query_type,$scan); > }; > } else { > $pasarParams .= '&query=' . uri_escape_utf8($query); >@@ -631,7 +629,7 @@ if ($tag) { > $pasarParams .= '&query_type=' . uri_escape_utf8($query_type) if ($query_type); > my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; > eval { >- ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes_nocategory,$query_type,$scan,1); >+ ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1); > }; > } > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index e7344b6fcb..980803da6f 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -178,7 +178,7 @@ subtest 'build_authorities_query_compat() tests' => sub { > }; > > subtest 'build_query tests' => sub { >- plan tests => 38; >+ plan tests => 40; > > my $qb; > >@@ -205,6 +205,11 @@ subtest 'build_query tests' => sub { > "sort parameter properly formed" > ); > >+ t::lib::Mocks::mock_preference('FacetMaxCount','37'); >+ $query = $qb->build_query('test', %options); >+ ok( defined $query->{aggregations}{ccode}{terms}{size},'we need to ask for a size or we get only 5 facet' ); >+ is( $query->{aggregations}{ccode}{terms}{size}, 37,'we ask for the size as defined by the syspref FacetMaxCount'); >+ > t::lib::Mocks::mock_preference('DisplayLibraryFacets','both'); > $query = $qb->build_query(); > ok( defined $query->{aggregations}{homebranch}, >diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t >index b357b7b9c3..d40bc166a9 100644 >--- a/t/db_dependent/Search.t >+++ b/t/db_dependent/Search.t >@@ -347,12 +347,12 @@ sub run_marc21_search_tests { > my $results_hashref; > my $facets_loop; > ( undef, $results_hashref, $facets_loop ) = >- getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'ccl', undef); > is($results_hashref->{biblioserver}->{hits}, 101, "getRecords keyword search for 'book' matched right number of records"); > is(scalar @{$results_hashref->{biblioserver}->{RECORDS}}, 19, "getRecords returned requested number of records"); > my $record5 = $results_hashref->{biblioserver}->{RECORDS}->[5]; > ( undef, $results_hashref, $facets_loop ) = >- getRecords('kw:book', 'book', [], [ 'biblioserver' ], '20', 5, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('kw:book', 'book', [], [ 'biblioserver' ], '20', 5, \%branches, \%itemtypes, 'ccl', undef); > ok(!defined $results_hashref->{biblioserver}->{RECORDS}->[0] && > !defined $results_hashref->{biblioserver}->{RECORDS}->[1] && > !defined $results_hashref->{biblioserver}->{RECORDS}->[2] && >@@ -361,50 +361,50 @@ sub run_marc21_search_tests { > $results_hashref->{biblioserver}->{RECORDS}->[5] eq $record5, "getRecords cursor works"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('ti:book', 'ti:book', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('ti:book', 'ti:book', [], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef); > is($results_hashref->{biblioserver}->{hits}, 11, "getRecords title search for 'book' matched right number of records"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef); > is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'ccl', undef); > ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Efectos del ambiente/ && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ > , "Simple relevance sorting in getRecords matches old behavior"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef); > ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[6],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' > , "Simple ascending author sorting in getRecords matches old behavior"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef); > ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[12],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ > , "Simple descending author sorting in getRecords matches old behavior"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef); > ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ > , "Simple ascending publication date sorting in getRecords matches old behavior"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, \%branches, \%itemtypes, 'ccl', undef); > ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Estado de salud/ && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' && > MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' > , "Simple descending publication date sorting in getRecords matches old behavior"); > > ( undef, $results_hashref, $facets_loop ) = >- getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1); >+ getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, undef, 1); > $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]); > is($record->title_proper(), 'Books', "Scan returned requested item"); > is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term"); >@@ -418,7 +418,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en'); > like($query, qr/kw\W.*salud/, "Built CCL keyword query"); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 19, "getRecords generated keyword search for 'salud' matched right number of records"); > > my @newresults = searchResults({'interface' => 'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 18, 0, 0, >@@ -430,7 +430,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); > like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query"); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' explicit-and 'higiene' matched right number of records"); > > ( $error, $query, $simple_query, $query_cgi, >@@ -438,7 +438,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); > like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query"); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 20, "getRecords generated composed keyword search for 'salud' explicit-or 'higiene' matched right number of records"); > > ( $error, $query, $simple_query, $query_cgi, >@@ -446,7 +446,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); > like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query"); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' implicit-and 'higiene' matched right number of records"); > > ( $error, $query, $simple_query, $query_cgi, >@@ -455,7 +455,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly"); > unlike($query_desc, qr/Laboratorios/, "Facets not included in query description"); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated faceted search matched right number of records"); > > >@@ -463,7 +463,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records"); > > >@@ -471,13 +471,13 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'NEKLS' ], [ 'Code-institution' ], [], [], 0, 'en'); >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 12, > 'search using index whose name contains "ns" returns expected results (bug 10271)'); > >@@ -485,12 +485,12 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'book' ], [ 'kw' ], [], [], 0, 'en'); >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 101, "Search for 'book' with index set to 'kw' returns 101 hits"); > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([ 'and' ], [ 'book', 'another' ], [ 'kw', 'kw' ], [], [], 0, 'en'); >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'kw:book && kw:another' returns 1 hit"); > $UseQueryParser = 0; > >@@ -498,7 +498,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated availability-limited search matched right number of records"); > > @newresults = searchResults({'interface'=>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0, >@@ -514,28 +514,28 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 180, "getRecords on _ALLRECORDS PQF returned all records"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches"); > > $QueryStemming = $QueryAutoTruncate = $QueryFuzzy = 0; >@@ -544,7 +544,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results"); > is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first"); > >@@ -554,14 +554,14 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches with automatic truncation on"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on"); > > $QueryStemming = $QueryFuzzy = $QueryAutoTruncate = 0; >@@ -569,13 +569,13 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'web application' ], [ 'kw' ], [], [], 0, 'en'); >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web application' returns one hit with QueryWeightFields on"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'web "application' ], [ 'kw' ], [], [], 0, 'en'); >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web \"application' returns one hit with QueryWeightFields on (bug 7518)"); > > $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0; >@@ -583,14 +583,14 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off"); > > ( $error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off"); > > $QueryStemming = $QueryWeightFields = 1; >@@ -599,7 +599,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on"); > > $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0; >@@ -607,7 +607,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en'); > >- ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off"); > > ( $error, $query, $simple_query, $query_cgi, >@@ -629,16 +629,16 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > isnt($error, undef, "SimpleSearch returns an error when passed gibberish"); > > warning_like {( undef, $results_hashref, $facets_loop ) = >- getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'nonsense', undef) } >+ getRecords('kw:book', 'book', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'nonsense', undef) } > qr/Unknown query_type/, "getRecords warns about unknown query type"; > > warning_like {( undef, $results_hashref, $facets_loop ) = >- getRecords('pqf=@attr 1=4 "title"', 'pqf=@attr 1=4 "title"', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, '', undef) } >+ getRecords('pqf=@attr 1=4 "title"', 'pqf=@attr 1=4 "title"', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, '', undef) } > qr/WARNING: query problem/, "getRecords warns when query type is not specified for non-CCL query"; > > # Let's just test a few other bits and bobs, just for fun > >- ($error, $results_hashref, $facets_loop) = getRecords("Godzina pÄsowej róży","Godzina pÄsowej róży",[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords("Godzina pÄsowej róży","Godzina pÄsowej róży",[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0, > $results_hashref->{'biblioserver'}->{"RECORDS"}); > is($newresults[0]->{'alternateholdings_count'}, 1, 'Alternate holdings filled in correctly'); >@@ -657,14 +657,14 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > } > }); > >- ($error, $results_hashref, $facets_loop) = getRecords("TEST12121212","TEST12121212",[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); >+ ($error, $results_hashref, $facets_loop) = getRecords("TEST12121212","TEST12121212",[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0); > @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0, > $results_hashref->{'biblioserver'}->{"RECORDS"}); > ok(!exists($newresults[0]->{norequests}), 'presence of a transit does not block hold request action (bug 10741)'); > > ## Regression test for bug 10684 > ( undef, $results_hashref, $facets_loop ) = >- getRecords('ti:punctuation', 'punctuation', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('ti:punctuation', 'punctuation', [], [ 'biblioserver' ], '19', 0, \%branches, \%itemtypes, 'ccl', undef); > is($results_hashref->{biblioserver}->{hits}, 1, "search for ti:punctuation returned expected number of records"); > warning_like { @newresults = searchResults({'intranet' => 'intranet'}, $query_desc, > $results_hashref->{'biblioserver'}->{'hits'}, 20, 0, 0, >@@ -812,7 +812,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > > # retrieve records that are larger than the MARC limit of 99,999 octets > ( undef, $results_hashref, $facets_loop ) = >- getRecords('ti:marc the large record', '', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef); >+ getRecords('ti:marc the large record', '', [], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef); > is($results_hashref->{biblioserver}->{hits}, 1, "Can do a search that retrieves an over-large bib record (bug 11096)"); > @newresults = searchResults({'interface' =>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 10, 0, 0, > $results_hashref->{'biblioserver'}->{"RECORDS"}); >@@ -829,7 +829,7 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > # verify that we don't attempt to sort if no results were returned > # because of a query error > warning_like {( undef, $results_hashref, $facets_loop ) = >- getRecords('ccl=( AND )', '', ['title_az'], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef) >+ getRecords('ccl=( AND )', '', ['title_az'], [ 'biblioserver' ], '20', 0, \%branches, \%itemtypes, 'ccl', undef) > } qr/WARNING: query problem with/, 'got warning instead of crash when attempting to run invalid query (bug 9578)'; > > # Test facet calculation >@@ -860,24 +860,15 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' > # Test _get_facets_info > my $facets_info = C4::Search::_get_facets_info( $facets ); > my $expected_facets_info_marc21 = { >- 'au' => { 'expanded' => undef, >- 'label_value' => "Authors" }, >- 'ccode' => { 'expanded' => undef, >- 'label_value' => "CollectionCodes" }, >- 'holdingbranch' => { 'expanded' => undef, >- 'label_value' => "HoldingLibrary" }, >- 'itype' => { 'expanded' => undef, >- 'label_value' => "ItemTypes" }, >- 'location' => { 'expanded' => undef, >- 'label_value' => "Location" }, >- 'se' => { 'expanded' => undef, >- 'label_value' => "Series" }, >- 'su-geo' => { 'expanded' => undef, >- 'label_value' => "Places" }, >- 'su-to' => { 'expanded' => undef, >- 'label_value' => "Topics" }, >- 'su-ut' => { 'expanded' => undef, >- 'label_value' => "Titles" } >+ 'au' => { 'label_value' => "Authors" }, >+ 'ccode' => { 'label_value' => "CollectionCodes" }, >+ 'holdingbranch' => { 'label_value' => "HoldingLibrary" }, >+ 'itype' => { 'label_value' => "ItemTypes" }, >+ 'location' => { 'label_value' => "Location" }, >+ 'se' => { 'label_value' => "Series" }, >+ 'su-geo' => { 'label_value' => "Places" }, >+ 'su-to' => { 'label_value' => "Topics" }, >+ 'su-ut' => { 'label_value' => "Titles" } > }; > delete $expected_facets_info_marc21->{holdingbranch} > if Koha::Libraries->count == 1; >@@ -959,22 +950,14 @@ sub run_unimarc_search_tests { > my $facets = C4::Koha::getFacets(); > my $facets_info = C4::Search::_get_facets_info( $facets ); > my $expected_facets_info_unimarc = { >- 'au' => { 'expanded' => undef, >- 'label_value' => "Authors" }, >- 'ccode' => { 'expanded' => undef, >- 'label_value' => "CollectionCodes" }, >- 'holdingbranch' => { 'expanded' => undef, >- 'label_value' => "HoldingLibrary" }, >- 'location' => { 'expanded' => undef, >- 'label_value' => "Location" }, >- 'se' => { 'expanded' => undef, >- 'label_value' => "Series" }, >- 'su-geo' => { 'expanded' => undef, >- 'label_value' => "Places" }, >- 'su-to' => { 'expanded' => undef, >- 'label_value' => "Topics" }, >- 'su-ut' => { 'expanded' => undef, >- 'label_value' => "Titles" } >+ 'au' => { 'label_value' => "Authors" }, >+ 'ccode' => { 'label_value' => "CollectionCodes" }, >+ 'holdingbranch' => { 'label_value' => "HoldingLibrary" }, >+ 'location' => { 'label_value' => "Location" }, >+ 'se' => { 'label_value' => "Series" }, >+ 'su-geo' => { 'label_value' => "Places" }, >+ 'su-to' => { 'label_value' => "Topics" }, >+ 'su-ut' => { 'label_value' => "Titles" } > }; > delete $expected_facets_info_unimarc->{holdingbranch} > if Koha::Libraries->count == 1; >-- >2.11.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 14419
:
40339
|
40425
|
91185
|
91234
|
91241
|
91242
| 96355