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 |
- |
|
|