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 217-223 subtest 'build_authorities_query_compat() tests' => sub { Link Here
217
};
217
};
218
218
219
subtest 'build_query tests' => sub {
219
subtest 'build_query tests' => sub {
220
    plan tests => 57;
220
    plan tests => 59;
221
221
222
    my $qb;
222
    my $qb;
223
223
Lines 496-501 subtest 'build_query tests' => sub { Link Here
496
        "Limits quoted correctly when passed as phrase"
496
        "Limits quoted correctly when passed as phrase"
497
    );
497
    );
498
498
499
    ( undef, $query ) = $qb->build_query_compat( ['OR'], ['title:"donald duck"', 'author:"Dillinger Escaplan"'], undef, ['itype:BOOK'] );
500
    is(
501
        $query->{query}{query_string}{query},
502
        '((title:"donald duck") OR (author:"Dillinger Escaplan")) AND itype:("BOOK")',
503
        "OR query with limit"
504
    );
505
506
    ( undef, $query ) = $qb->build_query_compat( undef, undef, undef, ['itype:BOOK'] );
507
    is(
508
        $query->{query}{query_string}{query},
509
        'itype:("BOOK")',
510
        "Limit only"
511
    );
512
499
    # Scan queries
513
    # Scan queries
500
    ( undef, $query, $simple_query, $query_cgi, $query_desc ) = $qb->build_query_compat( undef, ['new'], ['au'], undef, undef, 1 );
514
    ( undef, $query, $simple_query, $query_cgi, $query_desc ) = $qb->build_query_compat( undef, ['new'], ['au'], undef, undef, 1 );
501
    is(
515
    is(
502
- 

Return to bug 30152