From 80c0223a32e4d98c0b4cceb3a1c8e492b0b6da80 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 22 Jun 2020 09:10:33 +0200 Subject: [PATCH] Bug 25838: Sort facets values by number of occurrences (Zebra) Actually with Zebra facets values are sorted alphabetically. This is a comment from Bug 12478 : << Bug 12478: Display facet terms ordered by number of occurrences By default ES returns the facet terms ordered by most used, which makes sense. This patch removes resort done in the scripts (catalogue/search.pl and opac/opac-search.pl) and moves it to the module. For Zebra it's now done in C4::Search::getRecords, and there is no change to expect (still alphabetically). >> Looks like the sort by number of occurrences is already done in C4::Search::getRecords, it is an additionnal code that re-sort alphabetically. This patch proposes to remove it in order to have same sort order between Zebra and ES. Test plan : 1) Use Zebra searchengine and enable system preference 'displayFacetCount' 2) Without patch : 3) Perform a search with a lot of results 4) Look at facet author => You see sort is alphabetical (A to Z) 5) Apply patch : 6) Perform the same search 7) Look at facet author => You see sort is by number of occurrences decreasing --- C4/Search.pm | 7 ------- 1 file changed, 7 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 8997dba064..00b74b1f98 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -594,13 +594,6 @@ sub getRecords { } ); - # This sorts the facets into alphabetical order - if (@facets_loop) { - foreach my $f (@facets_loop) { - $f->{facets} = [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ]; - } - } - return ( undef, $results_hashref, \@facets_loop ); } -- 2.27.0