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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-14 / +14 lines)
Lines 47-53 use Modern::Perl; Link Here
47
use URI::Escape;
47
use URI::Escape;
48
48
49
use C4::Context;
49
use C4::Context;
50
use Data::Dumper;    # TODO remove
50
use Koha::Exceptions;
51
51
52
=head2 build_query
52
=head2 build_query
53
53
Lines 409-414 appropriate search object. Link Here
409
409
410
=cut
410
=cut
411
411
412
our $koha_to_index_name = {
413
    mainmainentry   => 'Heading-Main',
414
    mainentry       => 'Heading',
415
    match           => 'Match',
416
    'match-heading' => 'Match-heading',
417
    'see-from'      => 'Match-heading-see-from',
418
    thesaurus       => 'Subject-heading-thesaurus',
419
    any              => ''
420
};
421
412
sub build_authorities_query_compat {
422
sub build_authorities_query_compat {
413
    my ( $self, $marclist, $and_or, $excluding, $operator, $value,
423
    my ( $self, $marclist, $and_or, $excluding, $operator, $value,
414
        $authtypecode, $orderby )
424
        $authtypecode, $orderby )
Lines 418-441 sub build_authorities_query_compat { Link Here
418
    # extensible hash form that is understood by L<build_authorities_query>.
428
    # extensible hash form that is understood by L<build_authorities_query>.
419
    my @searches;
429
    my @searches;
420
430
421
    my %koha_to_index_name = (
422
        mainmainentry   => 'Heading-Main',
423
        mainentry       => 'Heading',
424
        match           => 'Match',
425
        'match-heading' => 'Match-heading',
426
        'see-from'      => 'Match-heading-see-from',
427
        thesaurus       => 'Subject-heading-thesaurus',
428
        any              => '',
429
    );
430
431
    # Make sure everything exists
431
    # Make sure everything exists
432
    foreach my $m (@$marclist) {
432
    foreach my $m (@$marclist) {
433
        confess "Invalid marclist field provided: $m" unless exists $koha_to_index_name{$m};
433
        Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m")
434
            unless exists $koha_to_index_name->{$m};
434
    }
435
    }
435
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
436
    for ( my $i = 0 ; $i < @$value ; $i++ ) {
436
        push @searches,
437
        push @searches,
437
          {
438
          {
438
            where    => $koha_to_index_name{$marclist->[$i]},
439
            where    => $koha_to_index_name->{$marclist->[$i]},
439
            operator => $operator->[$i],
440
            operator => $operator->[$i],
440
            value    => $value->[$i],
441
            value    => $value->[$i],
441
          };
442
          };
442
- 

Return to bug 18624