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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-3 / +5 lines)
Lines 432-437 sub build_authorities_query_compat { Link Here
432
432
433
    # Convert to lower case
433
    # Convert to lower case
434
    $marclist = [map(lc, @{$marclist})];
434
    $marclist = [map(lc, @{$marclist})];
435
    $orderby  = lc $orderby;
435
436
436
    # Make sure everything exists
437
    # Make sure everything exists
437
    foreach my $m (@$marclist) {
438
    foreach my $m (@$marclist) {
Lines 454-460 sub build_authorities_query_compat { Link Here
454
      : ( $orderby =~ /^auth/ )    ? 'local-number'
455
      : ( $orderby =~ /^auth/ )    ? 'local-number'
455
      :                              undef;
456
      :                              undef;
456
    if ($sort_field) {
457
    if ($sort_field) {
457
        my $sort_order = ( $orderby =~ /Asc$/ ) ? 'asc' : 'desc';
458
        my $sort_order = ( $orderby =~ /asc$/ ) ? 'asc' : 'desc';
458
        %sort = ( $sort_field => $sort_order, );
459
        %sort = ( $sort_field => $sort_order, );
459
    }
460
    }
460
    my %search = (
461
    my %search = (
Lines 887-893 operands and double quoted strings. Link Here
887
888
888
=cut
889
=cut
889
890
890
my $tokenize_split_re = qr/((?:${field_name_pattern}${multi_field_pattern}:)?"[^"]+"|\s+)/;
891
sub _truncate_terms {
891
sub _truncate_terms {
892
    my ( $self, $query ) = @_;
892
    my ( $self, $query ) = @_;
893
893
Lines 914-925 any field prefixes and quoted strings. Link Here
914
914
915
=cut
915
=cut
916
916
917
my $tokenize_split_re = qr/((?:${field_name_pattern}${multi_field_pattern}:)?"[^"]+"|\s+)/;
918
917
sub _split_query {
919
sub _split_query {
918
    my ( $self, $query ) = @_;
920
    my ( $self, $query ) = @_;
919
921
920
    # '"donald duck" title:"the mouse" and peter" get split into
922
    # '"donald duck" title:"the mouse" and peter" get split into
921
    # ['', '"donald duck"', '', ' ', '', 'title:"the mouse"', '', ' ', 'and', ' ', 'pete']
923
    # ['', '"donald duck"', '', ' ', '', 'title:"the mouse"', '', ' ', 'and', ' ', 'pete']
922
    my @tokens = split /((?:[\w\-.]+:)?"[^"]+"|\s+)/, $query;
924
    my @tokens = split $tokenize_split_re, $query;
923
925
924
    # Filter out empty values
926
    # Filter out empty values
925
    @tokens = grep( /\S/, @tokens );
927
    @tokens = grep( /\S/, @tokens );
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-5 / +4 lines)
Lines 144-150 subtest 'build_authorities_query_compat() tests' => sub { Link Here
144
        $query->{sort},
144
        $query->{sort},
145
        [
145
        [
146
            {
146
            {
147
                'Heading__sort.phrase' => 'asc'
147
                'heading__sort' => 'asc'
148
            }
148
            }
149
        ],
149
        ],
150
        "ascending sort parameter properly formed"
150
        "ascending sort parameter properly formed"
Lines 154-160 subtest 'build_authorities_query_compat() tests' => sub { Link Here
154
        $query->{sort},
154
        $query->{sort},
155
        [
155
        [
156
            {
156
            {
157
                'Heading__sort.phrase' => 'desc'
157
                'heading__sort' => 'desc'
158
            }
158
            }
159
        ],
159
        ],
160
        "descending sort parameter properly formed"
160
        "descending sort parameter properly formed"
Lines 428-434 subtest "_convert_sort_fields() tests" => sub { Link Here
428
    is_deeply(
428
    is_deeply(
429
        \@sort_by,
429
        \@sort_by,
430
        [
430
        [
431
            { field => 'callnum', direction => 'asc' },
431
            { field => 'local-classification', direction => 'asc' },
432
            { field => 'author',  direction => 'desc' }
432
            { field => 'author',  direction => 'desc' }
433
        ],
433
        ],
434
        'sort fields should have been split correctly'
434
        'sort fields should have been split correctly'
Lines 439-445 subtest "_convert_sort_fields() tests" => sub { Link Here
439
    is_deeply(
439
    is_deeply(
440
        \@sort_by,
440
        \@sort_by,
441
        [
441
        [
442
            { field => 'callnum', direction => 'asc' },
442
            { field => 'local-classification', direction => 'asc' },
443
            { field => 'author',  direction => 'desc' }
443
            { field => 'author',  direction => 'desc' }
444
        ],
444
        ],
445
        'sort fields should have been split correctly'
445
        'sort fields should have been split correctly'
446
- 

Return to bug 19575