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
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
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?
(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 ?
(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
Ohhhh thanks a lot. Field issues is indeed type sum. This is for the best ;) I mark this as invalid.