Lines 315-321
sub build_authorities_query {
Link Here
|
315 |
foreach my $s ( @{ $search->{searches} } ) { |
315 |
foreach my $s ( @{ $search->{searches} } ) { |
316 |
my ( $wh, $op, $val ) = @{$s}{qw(where operator value)}; |
316 |
my ( $wh, $op, $val ) = @{$s}{qw(where operator value)}; |
317 |
$wh = '_all' if $wh eq ''; |
317 |
$wh = '_all' if $wh eq ''; |
318 |
if ( $op eq 'is' || $op eq '=' || $op eq 'exact' ) { |
318 |
if ( defined $op && ($op eq 'is' || $op eq '=' || $op eq 'exact') ) { |
319 |
|
319 |
|
320 |
# look for something that matches a term completely |
320 |
# look for something that matches a term completely |
321 |
# note, '=' is about numerical vals. May need special handling. |
321 |
# note, '=' is about numerical vals. May need special handling. |
Lines 324-330
sub build_authorities_query {
Link Here
|
324 |
# search analyzer applied to them. |
324 |
# search analyzer applied to them. |
325 |
push @query_parts, { match_phrase => {"$wh.phrase" => lc $val} }; |
325 |
push @query_parts, { match_phrase => {"$wh.phrase" => lc $val} }; |
326 |
} |
326 |
} |
327 |
elsif ( $op eq 'start' ) { |
327 |
elsif ( defined $op && $op eq 'start' ) { |
328 |
# startswith search, uses lowercase untokenized version of heading |
328 |
# startswith search, uses lowercase untokenized version of heading |
329 |
push @query_parts, { match_phrase_prefix => {"$wh.phrase" => lc $val} }; |
329 |
push @query_parts, { match_phrase_prefix => {"$wh.phrase" => lc $val} }; |
330 |
} |
330 |
} |
Lines 449-469
sub build_authorities_query_compat {
Link Here
|
449 |
# This turns the old-style many-options argument form into a more |
449 |
# This turns the old-style many-options argument form into a more |
450 |
# extensible hash form that is understood by L<build_authorities_query>. |
450 |
# extensible hash form that is understood by L<build_authorities_query>. |
451 |
my @searches; |
451 |
my @searches; |
|
|
452 |
my $mappings = $self->get_elasticsearch_mappings(); |
452 |
|
453 |
|
453 |
# Convert to lower case |
454 |
# Convert to lower case |
454 |
$marclist = [map(lc, @{$marclist})]; |
455 |
$marclist = [map(lc, @{$marclist})]; |
455 |
$orderby = lc $orderby; |
456 |
$orderby = lc $orderby; |
456 |
|
457 |
|
|
|
458 |
my @indexes; |
457 |
# Make sure everything exists |
459 |
# Make sure everything exists |
458 |
foreach my $m (@$marclist) { |
460 |
foreach my $m (@$marclist) { |
459 |
Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m") |
461 |
|
460 |
unless exists $koha_to_index_name->{$m}; |
462 |
$m = exists $koha_to_index_name->{$m} ? $koha_to_index_name->{$m} : $m; |
|
|
463 |
push @indexes, $m; |
464 |
warn "Unknown search field $m in marclist" unless (defined $mappings->{data}->{properties}->{$m} || $m eq ''); |
461 |
} |
465 |
} |
462 |
for ( my $i = 0 ; $i < @$value ; $i++ ) { |
466 |
for ( my $i = 0 ; $i < @$value ; $i++ ) { |
463 |
next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches |
467 |
next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches |
464 |
push @searches, |
468 |
push @searches, |
465 |
{ |
469 |
{ |
466 |
where => $koha_to_index_name->{$marclist->[$i]}, |
470 |
where => $indexes[$i], |
467 |
operator => $operator->[$i], |
471 |
operator => $operator->[$i], |
468 |
value => $value->[$i], |
472 |
value => $value->[$i], |
469 |
}; |
473 |
}; |