From 2db20445a130d5632b47e97525a4c781855b6a2e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 16 Mar 2018 11:10:37 +0000 Subject: [PATCH] Bug 19502: Limit pagination to first 10000 results when using ES MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch is to avoid hitting an error page. We should eventually make the max number returned configurable for ES. To test: 1 - Have Koha running ES with 10,000+ records 2 - Search for '*' 3 - Click 'Last' to view last page of results 4 - 'Cannot perform search' error 5 - Apply patch 6 - Search again 7 - View 'Last' page 8 - No error, you go to the last of 10000 9 - Note the warning above the pagination buttons Signed-off-by: Séverine QUEUNE Signed-off-by: Nick Clemens Signed-off-by: Alex Arnaud Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize (cherry picked from commit 7bff14830df7eab4b9a6c57d017846af4f79da5e) Signed-off-by: Fridolin Somers --- catalogue/search.pl | 3 ++- koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc | 1 + koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt | 1 - koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc | 1 + .../opac-tmpl/bootstrap/en/includes/search/page-numbers.inc | 1 + opac/opac-search.pl | 3 ++- 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 9f752217c7..589608bad4 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -612,8 +612,9 @@ for (my $i=0;$i<@servers;$i++) { ## FIXME: add a global function for this, it's better than the current global one ## Build the page numbers on the bottom of the page my @page_numbers; + my $hits_to_paginate = C4::Context->preference('SearchEngine') eq 'Elasticsearch' ? 10000 : $hits; # total number of pages there will be - my $pages = ceil($hits / $results_per_page); + my $pages = ceil($hits_to_paginate / $results_per_page); my $last_page_offset = ( $pages -1 ) * $results_per_page; # default page number my $current_page_number = 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc index 1c9bd33723..ad80c3ce49 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc @@ -1,4 +1,5 @@ [% IF ( PAGE_NUMBERS ) %]