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

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

Return to bug 23719