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

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

Return to bug 23887