Bug 25838 - Sort facets values by number of occurrences (Zebra)
Summary: Sort facets values by number of occurrences (Zebra)
Status: RESOLVED DUPLICATE of bug 28826
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Zebra (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Fridolin Somers
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-22 07:05 UTC by Fridolin Somers
Modified: 2021-10-05 10:12 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 25838: Sort facets values by number of occurrences (Zebra) (1.82 KB, patch)
2020-06-22 07:13 UTC, Fridolin Somers
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2020-06-22 07:05:47 UTC
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.
Comment 1 Fridolin Somers 2020-06-22 07:13:22 UTC
Created attachment 106145 [details] [review]
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
Comment 2 Katrin Fischer 2020-06-22 10:24:28 UTC
I am not sure about this change for Zebra. We have turned off Zebra facets (using Koha Zebra facets) in almost all installations because it creates a huge hit on performance. If you use Koha facetting it will only count the first pages occurrences... and sorting by that is really bad. I'd prefer the alphabetic for Zebra Koha facets at least.
Comment 3 Fridolin Somers 2020-06-24 10:07:52 UTC
(In reply to Katrin Fischer from comment #2)
> I am not sure about this change for Zebra. We have turned off Zebra facets
> (using Koha Zebra facets) in almost all installations because it creates a
> huge hit on performance. If you use Koha facetting it will only count the
> first pages occurrences... and sorting by that is really bad. I'd prefer the
> alphabetic for Zebra Koha facets at least.

Indeed this appears with Zebra facets OFF, its pure perl code in C4/Search.pm.
Even with the first pages limitation, consistency with ES is good i think.

Or a system preference ?
Comment 4 Katrin Fischer 2020-06-24 20:19:49 UTC
Elastic gives you real facets... so I am torn. Maybe good to get another opinion here. My worry is that it might give a wrong impression... but our limited Zebra facets might always do that?
Comment 5 David Cook 2020-06-25 06:44:18 UTC
Looks like a fairly trivial change at a glance?
Comment 6 Katrin Fischer 2020-06-25 06:46:30 UTC
I believe it works, the question is about presentation in the OPAC - sorting alphabetic or by occurrence. As we only look for occurrences on the first page the numbers are inaccurate (with no Zebra facets). So I was saying I prefer alphabetic because it does maybe give less of a false impression.

Comparing to Elastic facets doesn't work here I think as they work very differently and results should be much more trustable.
Comment 7 David Cook 2020-06-26 02:41:02 UTC
(In reply to Katrin Fischer from comment #6)
> I believe it works, the question is about presentation in the OPAC - sorting
> alphabetic or by occurrence. As we only look for occurrences on the first
> page the numbers are inaccurate (with no Zebra facets). So I was saying I
> prefer alphabetic because it does maybe give less of a false impression.
> 
> Comparing to Elastic facets doesn't work here I think as they work very
> differently and results should be much more trustable.

That's true, although maybe that's all the more reason to get rid of non-Zebra facets, and to more fully embrace Elasticsearch?
Comment 8 Katrin Fischer 2020-06-26 05:50:15 UTC
We can't yet. Elasticsearch is not widely used yet and won't be for quite a while (maybe some will never use it because of its requirements) and the Zebra facets are too slow. We tried, search times were horrible. We had to switch back.
Comment 9 Fridolin Somers 2020-06-26 07:26:39 UTC
Indeed non-Zebra facets are limited, what ever the sorting of the values.
But giving values by number of occurrences is in the definition of a facet in my opinion.
I'm trying to get more opinions by email.
Comment 10 Katrin Fischer 2020-06-26 08:06:07 UTC
Frido, I think you are right for "real" facets... but ours are not in case of Zebra. The occurence you sort after is only for the result set we look at - the first 20 records. I think it will cause a lot more questions about this wonky feature than help :(
Comment 11 Stefano Bargioni 2020-06-26 11:49:26 UTC
Zebra facetes are not reliable. One of the most important reasons for introducing Elasticsearch was this limitation. 
With Elastic, I suggest to sort by number of occurrences by default (or even by syspref). And if possible, also add sort by key.
Comment 12 Fridolin Somers 2020-06-26 15:21:01 UTC
Ok its indeed not simple to choose.
I set in discussion, and will close if does not move for a while.
Thanks for your time.
Comment 13 Fridolin Somers 2021-10-05 10:12:39 UTC

*** This bug has been marked as a duplicate of bug 28826 ***