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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-2 / +8 lines)
Lines 305-314 sub build_query_compat { Link Here
305
        # would be to pass them separately into build_query and let it build
305
        # would be to pass them separately into build_query and let it build
306
        # them into a structured ES query itself. Maybe later, though that'd be
306
        # them into a structured ES query itself. Maybe later, though that'd be
307
        # more robust.
307
        # more robust.
308
        $search_param_query_str = join( ' ', $self->_create_query_string(@search_params) );
308
        my @search_param_query_array = $self->_create_query_string(@search_params);
309
        $search_param_query_str = join( ' ', @search_param_query_array );
310
        my $search_param_limit_str =
311
          $self->_join_queries( $self->_convert_index_strings(@$limits) );
312
        if ( @search_param_query_array > 1 && $search_param_limit_str ) {
313
            $search_param_query_str = "($search_param_query_str)";
314
        }
309
        $query_str = join( ' AND ',
315
        $query_str = join( ' AND ',
310
            $search_param_query_str || (),
316
            $search_param_query_str || (),
311
            $self->_join_queries( $self->_convert_index_strings(@$limits) ) || () );
317
            $search_param_limit_str || () );
312
318
313
        # If there's no query on the left, let's remove the junk left behind
319
        # If there's no query on the left, let's remove the junk left behind
314
        $query_str =~ s/^ AND //;
320
        $query_str =~ s/^ AND //;
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-2 / +15 lines)
Lines 215-221 subtest 'build_authorities_query_compat() tests' => sub { Link Here
215
};
215
};
216
216
217
subtest 'build_query tests' => sub {
217
subtest 'build_query tests' => sub {
218
    plan tests => 57;
218
    plan tests => 59;
219
219
220
    my $qb;
220
    my $qb;
221
221
Lines 494-499 subtest 'build_query tests' => sub { Link Here
494
        "Limits quoted correctly when passed as phrase"
494
        "Limits quoted correctly when passed as phrase"
495
    );
495
    );
496
496
497
    ( undef, $query ) = $qb->build_query_compat( ['OR'], ['title:"donald duck"', 'author:"Dillinger Escaplan"'], undef, ['itype:BOOK'] );
498
    is(
499
        $query->{query}{query_string}{query},
500
        '((title:"donald duck") OR (author:"Dillinger Escaplan")) AND itype:("BOOK")',
501
        "OR query with limit"
502
    );
503
504
    ( undef, $query ) = $qb->build_query_compat( undef, undef, undef, ['itype:BOOK'] );
505
    is(
506
        $query->{query}{query_string}{query},
507
        'itype:("BOOK")',
508
        "Limit only"
509
    );
510
497
    # Scan queries
511
    # Scan queries
498
    ( undef, $query, $simple_query, $query_cgi, $query_desc ) = $qb->build_query_compat( undef, ['new'], ['au'], undef, undef, 1 );
512
    ( undef, $query, $simple_query, $query_cgi, $query_desc ) = $qb->build_query_compat( undef, ['new'], ['au'], undef, undef, 1 );
499
    is(
513
    is(
500
- 

Return to bug 30152