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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +1 lines)
Lines 283-289 sub build_query_compat { Link Here
283
        my @sort_params  = $self->_convert_sort_fields(@$sort_by);
283
        my @sort_params  = $self->_convert_sort_fields(@$sort_by);
284
        my @index_params = $self->_convert_index_fields(@$indexes);
284
        my @index_params = $self->_convert_index_fields(@$indexes);
285
        $limits       = $self->_fix_limit_special_cases($orig_limits);
285
        $limits       = $self->_fix_limit_special_cases($orig_limits);
286
        if ( $params->{suppress} ) { push @$limits, "suppress:false"; }
286
        if ( $params->{suppress} ) { push @$limits, "NOT(suppress:true)"; }
287
        # Merge the indexes in with the search terms and the operands so that
287
        # Merge the indexes in with the search terms and the operands so that
288
        # each search thing is a handy unit.
288
        # each search thing is a handy unit.
289
        unshift @$operators, undef;    # The first one can't have an op
289
        unshift @$operators, undef;    # The first one can't have an op
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-4 / +3 lines)
Lines 460-474 subtest 'build_query tests' => sub { Link Here
460
    ( undef, $query ) = $qb->build_query_compat( undef, ['title:"donald duck"'], undef, undef, undef, undef, undef, { suppress => 1 } );
460
    ( undef, $query ) = $qb->build_query_compat( undef, ['title:"donald duck"'], undef, undef, undef, undef, undef, { suppress => 1 } );
461
    is(
461
    is(
462
        $query->{query}{query_string}{query},
462
        $query->{query}{query_string}{query},
463
        '(title:"donald duck") AND suppress:false',
463
        '(title:"donald duck") AND NOT(suppress:true)',
464
        "query of specific field is added AND suppress:false"
464
        "suppress part of the query added correctly"
465
    );
465
    );
466
466
467
    ( undef, $query, $simple_query, $query_cgi, $query_desc ) = $qb->build_query_compat( undef, ['title:"donald duck"'], undef, undef, undef, undef, undef, { suppress => 0 } );
467
    ( undef, $query, $simple_query, $query_cgi, $query_desc ) = $qb->build_query_compat( undef, ['title:"donald duck"'], undef, undef, undef, undef, undef, { suppress => 0 } );
468
    is(
468
    is(
469
        $query->{query}{query_string}{query},
469
        $query->{query}{query_string}{query},
470
        '(title:"donald duck")',
470
        '(title:"donald duck")',
471
        "query of specific field is not added AND suppress:0"
471
        "suppress part of the query not added"
472
    );
472
    );
473
473
474
    ( undef, $query ) = $qb->build_query_compat( ['AND'], ['title:"donald duck"'], undef, ['author:Dillinger Escaplan'] );
474
    ( undef, $query ) = $qb->build_query_compat( ['AND'], ['title:"donald duck"'], undef, ['author:Dillinger Escaplan'] );
475
- 

Return to bug 31061