@@ -, +, @@ authorities in ES Use index: LC-card-number field: 010$a --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 6 +++--- .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -469,16 +469,16 @@ sub build_authorities_query_compat { $marclist = [map(lc, @{$marclist})]; $orderby = lc $orderby; + my @indexes; # Make sure everything exists foreach my $m (@$marclist) { - Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m") - unless exists $koha_to_index_name->{$m}; + push @indexes, exists $koha_to_index_name->{$m} ? $koha_to_index_name->{$m} : $m; } for ( my $i = 0 ; $i < @$value ; $i++ ) { next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches push @searches, { - where => $koha_to_index_name->{$marclist->[$i]}, + where => $indexes[$i], operator => $operator->[$i], value => $value->[$i], }; --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -91,7 +91,8 @@ my $clear_search_fields_cache = sub { }; subtest 'build_authorities_query_compat() tests' => sub { - plan tests => 55; + + plan tests => 56; my $qb; @@ -184,12 +185,19 @@ subtest 'build_authorities_query_compat() tests' => sub { "authorities type code is used as filter" ); - # Failing case - throws_ok { - $qb->build_authorities_query_compat( [ 'tomas' ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); - } - 'Koha::Exceptions::WrongParameter', - 'Exception thrown on invalid value in the marclist param'; + # Authorities marclist check + $query = $qb->build_authorities_query_compat( [ 'tomas','mainentry' ], undef, undef, ['contains'], [$search_term,$search_term], 'AUTH_TYPE', 'asc' ); + is_deeply( + $query->{query}->{bool}->{must}[0]->{query_string}->{default_field}, + 'tomas', + "If no mapping for marclist the index is passed through as defined" + ); + is_deeply( + $query->{query}->{bool}->{must}[1]->{query_string}{default_field}, + 'heading', + "If mapping found for marclist the index is passed through converted" + ); + }; subtest 'build_query tests' => sub { --