@@ -, +, @@ 1 - Perform an authorities search with 1+ pages using Zebra 2 - Page through results, note you are only offseeting by 1 each time 3 - Perform an authorities search with 10,000+ results in ES 4 - Click on the last page and get an error 5 - Apply patch 6 - Retry Zebra search 7 - Results should paginate correctly 8 - Clicking on last page should return last results 9 - Retry ES results --- Koha/SearchEngine/Elasticsearch/Search.pm | 4 +++- authorities/authorities-home.pl | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) --- a/Koha/SearchEngine/Elasticsearch/Search.pm +++ a/Koha/SearchEngine/Elasticsearch/Search.pm @@ -187,7 +187,9 @@ results in a form the same as L. sub search_auth_compat { my $self = shift; - # TODO handle paging + # FIXME the options here should match zebra - we take page, but should take offset + # page is calculated to offset in search above, though we can pass offset directly too + # via options my $database = Koha::Database->new(); my $schema = $database->schema(); my $res = $self->search(@_); --- a/authorities/authorities-home.pl +++ a/authorities/authorities-home.pl @@ -23,6 +23,7 @@ use warnings; use CGI qw ( -utf8 ); use URI::Escape; use C4::Auth; +use POSIX qw(ceil); use C4::Context; use C4::Auth; @@ -95,8 +96,9 @@ if ( $op eq "do_search" ) { [$marclist], [$and_or], [$excluding], [$operator], [$value], $authtypecode, $orderby ); + my $offset = ( $startfrom - 1 ) * $resultsperpage + 1; my ( $results, $total ) = $searcher->search_auth_compat( - $search_query, $startfrom, $resultsperpage + $search_query, $offset, $resultsperpage, ( offset => $offset - 1 ) ); ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -180,15 +182,18 @@ if ( $op eq "do_search" ) { $template->param( result => $results ) if $results; + my $max_result_window = $searcher->max_result_window; + my $hits_to_paginate = ($max_result_window && $max_result_window < $total) ? $max_result_window : $total; $template->param( pagination_bar => pagination_bar( - $base_url, int( $total / $resultsperpage ) + 1, + $base_url, ceil( $hits_to_paginate / $resultsperpage ) , $startfrom, 'startfrom' ), - total => $total, - from => $from, - to => $to, - isEDITORS => $authtypecode eq 'EDITORS', + total => $total, + hits_to_paginate => $hits_to_paginate, + from => $from, + to => $to, + isEDITORS => $authtypecode eq 'EDITORS', ); } --