Bug 27206 - Elasticsearch sort by popularity must use totalissues search field
Summary: Elasticsearch sort by popularity must use totalissues search field
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Fridolin Somers
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-11 14:33 UTC by Fridolin Somers
Modified: 2021-12-13 21:10 UTC (History)
1 user (show)

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


Attachments
Bug 27206: Elasticsearch sort by popularity must use totalissues search field (1.69 KB, patch)
2020-12-11 14:41 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-12-11 14:33:41 UTC
With Zebra search engine, sort by popularity uses search field 9003.
This is from bib1.att :
  att 9003    totalissues

Actually Elasticsearch sort by popularity uses search field 'issues' :
https://git.koha-community.org/Koha-community/Koha/src/commit/cae0ef76f398bb3d9f60235ff10611cc8d8eacb7/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm#L593
Comment 1 Fridolin Somers 2020-12-11 14:41:01 UTC
Created attachment 114344 [details] [review]
Bug 27206: Elasticsearch sort by popularity must use totalissues search field

With Zebra search engine, sort by popularity uses search field 9003.
This is from bib1.att : att 9003    totalissues
'totalissues' beeing on 942$0

Actually Elasticsearch sort by popularity uses search field 'issues' :
https://git.koha-community.org/Koha-community/Koha/src/commit/cae0ef76f398bb3d9f60235ff10611cc8d8eacb7/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm#L593

Test plan :
1) Use zebra search engine
2) Perform some checkouts and checkins
3) Run misc/cronjobs/update_totalissues.pl
4) Perform a search sorting on popularity
5) Change search engine to Elasticsearch
6) Rebuild all biblios : misc/search_tools/rebuild_elasticsearch.pl -b
7) Perform same search sorting on popularity
=> You should get same order
Comment 2 Nick Clemens (kidclamp) 2020-12-21 13:37:07 UTC
Elastic uses the sum of the 'issues' field which is set to the default of '952l' - so it should match the output when the totalissues field is counted using items.

If you want it to match totalissues using statistics table, then we could map it to 942$0

Using the sum of the issues from items means we don't rely on the cronjob to update_totalissues which is maybe a good thing?
Comment 3 Fridolin Somers 2020-12-22 09:12:00 UTC
(In reply to Nick Clemens from comment #2)
> Elastic uses the sum of the 'issues' field which is set to the default of
> '952l' - so it should match the output when the totalissues field is counted
> using items.
Ah sure.
But I don't see where Elastic does this sum ?
Comment 4 Nick Clemens (kidclamp) 2020-12-22 11:45:06 UTC
(In reply to Fridolin Somers from comment #3)
> (In reply to Nick Clemens from comment #2)
> > Elastic uses the sum of the 'issues' field which is set to the default of
> > '952l' - so it should match the output when the totalissues field is counted
> > using items.
> Ah sure.
> But I don't see where Elastic does this sum ?

https://git.koha-community.org/gitweb/?p=koha.git;a=blob;f=Koha/SearchEngine/Elasticsearch.pm;h=4a2d75d03decd5413ceb1969601d561ae8251f3f;hb=HEAD#l645
Comment 5 Fridolin Somers 2020-12-22 13:54:58 UTC
Ohhhh thanks a lot.

Field issues is indeed type sum.
This is for the best ;)

I mark this as invalid.