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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-3 / +3 lines)
Lines 450-465 sub build_authorities_query_compat { Link Here
450
    $marclist = [map(lc, @{$marclist})];
450
    $marclist = [map(lc, @{$marclist})];
451
    $orderby  = lc $orderby;
451
    $orderby  = lc $orderby;
452
452
453
    my @indexes;
453
    # Make sure everything exists
454
    # Make sure everything exists
454
    foreach my $m (@$marclist) {
455
    foreach my $m (@$marclist) {
455
        Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m")
456
        push @indexes, exists $koha_to_index_name->{$m} ? $koha_to_index_name->{$m} : $m;
456
            unless exists $koha_to_index_name->{$m};
457
    }
457
    }
458
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
458
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
459
        next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches
459
        next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches
460
        push @searches,
460
        push @searches,
461
          {
461
          {
462
            where    => $koha_to_index_name->{$marclist->[$i]},
462
            where    => $indexes[$i],
463
            operator => $operator->[$i],
463
            operator => $operator->[$i],
464
            value    => $value->[$i],
464
            value    => $value->[$i],
465
          };
465
          };
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-8 / +14 lines)
Lines 82-88 $se->mock( 'get_elasticsearch_mappings', sub { Link Here
82
});
82
});
83
83
84
subtest 'build_authorities_query_compat() tests' => sub {
84
subtest 'build_authorities_query_compat() tests' => sub {
85
    plan tests => 37;
85
    plan tests => 38;
86
86
87
    my $qb;
87
    my $qb;
88
88
Lines 168-179 subtest 'build_authorities_query_compat() tests' => sub { Link Here
168
        "authorities type code is used as filter"
168
        "authorities type code is used as filter"
169
    );
169
    );
170
170
171
    # Failing case
171
    # Authorities marclist check
172
    throws_ok {
172
    $query = $qb->build_authorities_query_compat( [ 'tomas','mainentry' ],  undef, undef, ['contains'], [$search_term,$search_term], 'AUTH_TYPE', 'asc' );
173
        $qb->build_authorities_query_compat( [ 'tomas' ],  undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' );
173
    is_deeply(
174
    }
174
        $query->{query}->{bool}->{must}[0]->{query_string}->{default_field},
175
    'Koha::Exceptions::WrongParameter',
175
        'tomas',
176
        'Exception thrown on invalid value in the marclist param';
176
        "If no mapping for marclist the index is passed through as defined"
177
    );
178
    is_deeply(
179
        $query->{query}->{bool}->{must}[1]->{query_string}{default_field},
180
        'heading',
181
        "If mapping found for marclist the index is passed through converted"
182
    );
183
177
};
184
};
178
185
179
subtest 'build_query tests' => sub {
186
subtest 'build_query tests' => sub {
180
- 

Return to bug 23719