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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-2 / +2 lines)
Lines 553-559 sub _convert_sort_fields { Link Here
553
        author      => 'author',
553
        author      => 'author',
554
        call_number => 'local-classification',
554
        call_number => 'local-classification',
555
        popularity  => 'issues',
555
        popularity  => 'issues',
556
        relevance   => undef,       # default
556
        relevance   => '',       # default
557
        title       => 'title',
557
        title       => 'title',
558
        pubdate     => 'date-of-publication',
558
        pubdate     => 'date-of-publication',
559
    );
559
    );
Lines 564-570 sub _convert_sort_fields { Link Here
564
    grep { $_->{field} } map {
564
    grep { $_->{field} } map {
565
        my ( $f, $d ) = /(.+)_(.+)/;
565
        my ( $f, $d ) = /(.+)_(.+)/;
566
        {
566
        {
567
            field     => $sort_field_convert{$f},
567
            field     => $sort_field_convert{$f} // $f,
568
            direction => $sort_order_convert{$d}
568
            direction => $sort_order_convert{$d}
569
        }
569
        }
570
    } @sort_by;
570
    } @sort_by;
(-)a/Koha/Z3950Responder/GenericSession.pm (-3 / +28 lines)
Lines 2-8 Link Here
2
2
3
package Koha::Z3950Responder::GenericSession;
3
package Koha::Z3950Responder::GenericSession;
4
4
5
# Copyright The National Library of Finland 2018
5
# Copyright The National Library of Finland 2018-2019
6
#
6
#
7
# This file is part of Koha.
7
# This file is part of Koha.
8
#
8
#
Lines 63-69 sub start_search { Link Here
63
    my $query = $args->{RPN}->{'query'}->to_koha($self->{'attribute_mappings'}->{$database});
63
    my $query = $args->{RPN}->{'query'}->to_koha($self->{'attribute_mappings'}->{$database});
64
    $self->log_debug("    parsed search: $query");
64
    $self->log_debug("    parsed search: $query");
65
    my @operands = $query;
65
    my @operands = $query;
66
    (undef, $built_query) = $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0);
66
    my $sort = $self->_convert_sort_rules($args->{SRW_SORTKEYS} // '');
67
68
    (undef, $built_query) = $builder->build_query_compat( undef, \@operands, undef, undef, $sort, 0);
67
69
68
    my ($error, $marcresults, $hits ) = $searcher->simple_search_compat($built_query, 0, $num_to_prefetch);
70
    my ($error, $marcresults, $hits ) = $searcher->simple_search_compat($built_query, 0, $num_to_prefetch);
69
    if (defined $error) {
71
    if (defined $error) {
Lines 110-113 sub fetch_record { Link Here
110
    return $resultset->{cached_results}[$offset - $resultset->{cached_offset}];
112
    return $resultset->{cached_results}[$offset - $resultset->{cached_offset}];
111
}
113
}
112
114
115
=head2 Internal methods
116
117
=head3 _convert_sort_rules
118
119
    my $sort = $self->_convert_sort_rules($srw_sortkeys);
120
121
Convert SRW_SORTKEYS from SimpleServer to Koha's format
122
123
=cut
124
125
sub _convert_sort_rules {
126
    my ( $self, $srw_sortkeys ) = @_;
127
128
    my @result;
129
    my @sortkeys = split(' ', $srw_sortkeys);
130
    foreach my $sortkey (@sortkeys) {
131
        my @parts = split(',', $sortkey);
132
        my $field = $parts[0];
133
        my $direction = $parts[2] // 1 == 1 ? 'asc' : 'desc';
134
        push @result, $field . '_' . $direction;
135
    }
136
    return \
137
}
138
113
1;
139
1;
114
- 

Return to bug 23887