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

(-)a/authorities/authorities-home.pl (-10 / +4 lines)
Lines 97-121 if ( $op eq "do_search" ) { Link Here
97
        }
97
        }
98
    );
98
    );
99
99
100
    my $builder = Koha::SearchEngine::QueryBuilder->new(
100
    my $builder  = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
101
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
101
    my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
102
    my $searcher = Koha::SearchEngine::Search->new(
103
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
104
102
105
    my $search_query = $builder->build_authorities_query_compat(
103
    my $search_query = $builder->build_authorities_query_compat(
106
        [$marclist], [$and_or], [$excluding], [$operator],
104
        [$marclist], [$and_or], [$excluding], [$operator],
107
        [$value], $authtypecode, $orderby
105
        [$value], $authtypecode, $orderby
108
    );
106
    );
109
    my ( $results, $total );
107
    my ( $results, $total );
110
    eval {
108
    eval { ( $results, $total ) = $searcher->search_auth_compat( $search_query, $offset, $resultsperpage ); };
111
        ( $results, $total ) = $searcher->search_auth_compat(
112
            $search_query, $offset, $resultsperpage
113
        );
114
    };
115
    if ($@) {
109
    if ($@) {
116
        my $query_error = q{};
110
        my $query_error = q{};
117
        $query_error .= $@ if $@;
111
        $query_error .= $@ if $@;
118
        $template->param(query_error => $query_error);
112
        $template->param( query_error => $query_error );
119
    }
113
    }
120
114
121
    $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate');
115
    $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate');
(-)a/t/Koha/SearchEngine/Elasticsearch/Search.t (-5 / +5 lines)
Lines 45-56 subtest 'search_auth_compat' => sub { Link Here
45
45
46
    my $search_query = $builder->build_authorities_query_compat(
46
    my $search_query = $builder->build_authorities_query_compat(
47
        ['mainmainentry'], ['and'], [''], ['contains'],
47
        ['mainmainentry'], ['and'], [''], ['contains'],
48
        ['Donald - Duck'], '',      'HeadingAsc'
48
        ['Donald - ^ \ ~ + Duck'], '', 'HeadingAsc'
49
    );
49
    );
50
50
51
    my ( $bad_results, undef ) = $search->search_auth_compat( $search_query, 0, 20, undef );
51
    is(
52
52
        $search_query->{query}->{bool}->{must}->[0]->{query_string}->{query}, '(Donald*) AND (Duck*)',
53
    is( @$bad_results[0], undef, 'We expect no record because it doesnt exist' );
53
        "Reserved characters -, ^, \\, ~, + have been removed from search query"
54
    );
54
55
55
    my $module = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
56
    my $module = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
56
    $module->mock( 'count_auth_use', sub { return 1 } );
57
    $module->mock( 'count_auth_use', sub { return 1 } );
57
- 

Return to bug 33406