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

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2018-03-16 11:10:37 +00:00
parent 2414a4e705
commit cc131475ed
6 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -1,4 +1,5 @@
[% IF ( PAGE_NUMBERS ) %]<nav><ul class="pagination">
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]<h6>10,000 results loaded, refine your search to view other records</h6>[% END %]
[% IF ( previous_page_offset.defined ) %]
<li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">First</a></li>
<!-- Row of numbers corresponding to search result pages -->

View File

@ -337,7 +337,6 @@
[% ELSE %]
<div id="searchresults">
[% INCLUDE 'page-numbers.inc' %]
<form action="/cgi-bin/koha/catalogue/search.pl" method="get" name="bookbag_form" id="bookbag_form">

View File

@ -1,5 +1,6 @@
[% IF ( PAGE_NUMBERS ) %]
<div class="pagination pagination-small noprint">
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]<h6>10000 results loaded, refine your search to view other records</h6>[% END %]
<ul>
[% IF ( previous_page_offset.defined ) %]
<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html %][% END %]">First</a></li>

View File

@ -1,5 +1,6 @@
[% IF ( PAGE_NUMBERS ) %]
<div class="pages">
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]<h6>10000 results loaded, refine your search to view other records</h6>[% END %]
[% IF ( previous_page ) %]
<a class="nav" href="?[% FOREACH fp IN follower_params %][% fp.var |url %]=[% fp.val |url %]&amp;[% END %]page=[% previous_page |url %]">&lt;&lt; Previous</a>
[% END %]

View File

@ -830,8 +830,9 @@ for (my $i=0;$i<@servers;$i++) {
}
## 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;