From f7cc972c6abe6c262b8f9ac2d10a8ecd31df9793 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 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 --- 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 + koha-tmpl/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 79ba83f..f9170c0 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 af4bc09..387d09f 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 ) %]