View | Details | Raw Unified | Return to bug 19502
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (+19 lines)
Lines 399-404 sub json2marc { Link Here
399
    return $marc;
399
    return $marc;
400
}
400
}
401
401
402
sub max_result_window {
403
    my ($self) = @_;
404
405
    $self->store(
406
        Catmandu::Store::ElasticSearch->new(%{ $self->get_elasticsearch_params })
407
    ) unless $self->store;
408
409
    my $index_name = $self->store->index_name;
410
    my $settings = $self->store->es->indices->get_settings(
411
        index  => $index_name,
412
        params => { include_defaults => 1, flat_settings => 1 },
413
    );
414
415
    my $max_result_window = $settings->{$index_name}->{settings}->{'index.max_result_window'};
416
    $max_result_window //= $settings->{$index_name}->{defaults}->{'index.max_result_window'};
417
418
    return $max_result_window;
419
}
420
402
=head2 _convert_facets
421
=head2 _convert_facets
403
422
404
    my $koha_facets = _convert_facets($es_facets, $expanded_facet);
423
    my $koha_facets = _convert_facets($es_facets, $expanded_facet);
(-)a/Koha/SearchEngine/Zebra/Search.pm (+2 lines)
Lines 110-113 sub search_auth_compat { Link Here
110
    C4::AuthoritiesMarc::SearchAuthorities(@params);
110
    C4::AuthoritiesMarc::SearchAuthorities(@params);
111
}
111
}
112
112
113
sub max_result_window { undef }
114
113
1;
115
1;
(-)a/catalogue/search.pl (-1 / +2 lines)
Lines 619-625 for (my $i=0;$i<@servers;$i++) { Link Here
619
            ## FIXME: add a global function for this, it's better than the current global one
619
            ## FIXME: add a global function for this, it's better than the current global one
620
            ## Build the page numbers on the bottom of the page
620
            ## Build the page numbers on the bottom of the page
621
            my @page_numbers;
621
            my @page_numbers;
622
            my $hits_to_paginate = C4::Context->preference('SearchEngine') eq 'Elasticsearch' ? 10000 : $hits;
622
            my $max_result_window = $searcher->max_result_window;
623
            my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
623
            $template->param( hits_to_paginate => $hits_to_paginate );
624
            $template->param( hits_to_paginate => $hits_to_paginate );
624
            # total number of pages there will be
625
            # total number of pages there will be
625
            my $pages = ceil($hits_to_paginate / $results_per_page);
626
            my $pages = ceil($hits_to_paginate / $results_per_page);
(-)a/opac/opac-search.pl (-1 / +2 lines)
Lines 830-836 for (my $i=0;$i<@servers;$i++) { Link Here
830
	    }
830
	    }
831
            ## Build the page numbers on the bottom of the page
831
            ## Build the page numbers on the bottom of the page
832
            my @page_numbers;
832
            my @page_numbers;
833
            my $hits_to_paginate = C4::Context->preference('SearchEngine') eq 'Elasticsearch' ? 10000 : $hits;
833
            my $max_result_window = $searcher->max_result_window;
834
            my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
834
            $template->param( hits_to_paginate => $hits_to_paginate );
835
            $template->param( hits_to_paginate => $hits_to_paginate );
835
            # total number of pages there will be
836
            # total number of pages there will be
836
            my $pages = ceil($hits_to_paginate / $results_per_page);
837
            my $pages = ceil($hits_to_paginate / $results_per_page);
(-)a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t (-3 / +13 lines)
Lines 17-26 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 13;
20
use Test::More tests => 15;
21
use t::lib::Mocks;
21
use t::lib::Mocks;
22
22
23
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
23
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
24
use Koha::SearchEngine::Elasticsearch::Indexer;
25
24
26
25
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
27
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
26
28
Lines 41-49 SKIP: { Link Here
41
43
42
    eval { $builder->get_elasticsearch_params; };
44
    eval { $builder->get_elasticsearch_params; };
43
45
44
    skip 'ElasticSeatch configuration not available', 6
46
    skip 'ElasticSeatch configuration not available', 8
45
        if $@;
47
        if $@;
46
48
49
    Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'mydb' })->drop_index;
50
47
    ok( my $results = $searcher->search( $query) , 'Do a search ' );
51
    ok( my $results = $searcher->search( $query) , 'Do a search ' );
48
52
49
    ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
53
    ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
Lines 56-61 SKIP: { Link Here
56
60
57
    is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');
61
    is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');
58
62
63
    is ($searcher->max_result_window, 10000, 'By default, max_result_window is 10000');
64
    $searcher->store->es->indices->put_settings(index => $searcher->store->index_name, body => {
65
        'index' => {
66
            'max_result_window' => 12000,
67
        },
68
    });
69
    is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value');
59
}
70
}
60
71
61
subtest 'json2marc' => sub {
72
subtest 'json2marc' => sub {
62
- 

Return to bug 19502