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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-3 / +3 lines)
Lines 500-515 sub build_authorities_query_compat { Link Here
500
    $marclist = [map(lc, @{$marclist})];
500
    $marclist = [map(lc, @{$marclist})];
501
    $orderby  = lc $orderby;
501
    $orderby  = lc $orderby;
502
502
503
    my @indexes;
503
    # Make sure everything exists
504
    # Make sure everything exists
504
    foreach my $m (@$marclist) {
505
    foreach my $m (@$marclist) {
505
        Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m")
506
        push @indexes, exists $koha_to_index_name->{$m} ? $koha_to_index_name->{$m} : $m;
506
            unless exists $koha_to_index_name->{$m};
507
    }
507
    }
508
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
508
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
509
        next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches
509
        next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches
510
        push @searches,
510
        push @searches,
511
          {
511
          {
512
            where    => $koha_to_index_name->{$marclist->[$i]},
512
            where    => $indexes[$i],
513
            operator => $operator->[$i],
513
            operator => $operator->[$i],
514
            value    => $value->[$i],
514
            value    => $value->[$i],
515
          };
515
          };
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-8 / +15 lines)
Lines 90-96 my $clear_search_fields_cache = sub { Link Here
90
};
90
};
91
91
92
subtest 'build_authorities_query_compat() tests' => sub {
92
subtest 'build_authorities_query_compat() tests' => sub {
93
    plan tests => 55;
93
94
    plan tests => 56;
94
95
95
    my $qb;
96
    my $qb;
96
97
Lines 183-194 subtest 'build_authorities_query_compat() tests' => sub { Link Here
183
        "authorities type code is used as filter"
184
        "authorities type code is used as filter"
184
    );
185
    );
185
186
186
    # Failing case
187
    # Authorities marclist check
187
    throws_ok {
188
    $query = $qb->build_authorities_query_compat( [ 'tomas','mainentry' ],  undef, undef, ['contains'], [$search_term,$search_term], 'AUTH_TYPE', 'asc' );
188
        $qb->build_authorities_query_compat( [ 'tomas' ],  undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' );
189
    is_deeply(
189
    }
190
        $query->{query}->{bool}->{must}[0]->{query_string}->{default_field},
190
    'Koha::Exceptions::WrongParameter',
191
        'tomas',
191
        'Exception thrown on invalid value in the marclist param';
192
        "If no mapping for marclist the index is passed through as defined"
193
    );
194
    is_deeply(
195
        $query->{query}->{bool}->{must}[1]->{query_string}{default_field},
196
        'heading',
197
        "If mapping found for marclist the index is passed through converted"
198
    );
199
192
};
200
};
193
201
194
subtest 'build_query tests' => sub {
202
subtest 'build_query tests' => sub {
195
- 

Return to bug 23719