return $marc;
}
+sub max_result_window {
+ my ($self) = @_;
+
+ $self->store(
+ Catmandu::Store::ElasticSearch->new(%{ $self->get_elasticsearch_params })
+ ) unless $self->store;
+
+ my $index_name = $self->store->index_name;
+ my $settings = $self->store->es->indices->get_settings(
+ index => $index_name,
+ params => { include_defaults => 1, flat_settings => 1 },
+ );
+
+ my $max_result_window = $settings->{$index_name}->{settings}->{'index.max_result_window'};
+ $max_result_window //= $settings->{$index_name}->{defaults}->{'index.max_result_window'};
+
+ return $max_result_window;
+}
+
=head2 _convert_facets
my $koha_facets = _convert_facets($es_facets, $expanded_facet);
C4::AuthoritiesMarc::SearchAuthorities(@params);
}
+sub max_result_window { undef }
+
1;
## 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;
+ my $max_result_window = $searcher->max_result_window;
+ my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
$template->param( hits_to_paginate => $hits_to_paginate );
# total number of pages there will be
my $pages = ceil($hits_to_paginate / $results_per_page);
}
## 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;
+ my $max_result_window = $searcher->max_result_window;
+ my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
$template->param( hits_to_paginate => $hits_to_paginate );
# total number of pages there will be
my $pages = ceil($hits_to_paginate / $results_per_page);
use Modern::Perl;
-use Test::More tests => 13;
+use Test::More tests => 15;
use t::lib::Mocks;
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
+use Koha::SearchEngine::Elasticsearch::Indexer;
+
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
eval { $builder->get_elasticsearch_params; };
- skip 'ElasticSeatch configuration not available', 6
+ skip 'ElasticSeatch configuration not available', 8
if $@;
+ Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'mydb' })->drop_index;
+
ok( my $results = $searcher->search( $query) , 'Do a search ' );
ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');
+ is ($searcher->max_result_window, 10000, 'By default, max_result_window is 10000');
+ $searcher->store->es->indices->put_settings(index => $searcher->store->index_name, body => {
+ 'index' => {
+ 'max_result_window' => 12000,
+ },
+ });
+ is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value');
}
subtest 'json2marc' => sub {