From cc131475eda2871afa2e5a4cf8f6f7191af06b31 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 --- 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 6fc96d638f..7e2e300523 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -619,8 +619,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 af4bc09c75..387d09f2fb 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 ) %]