|
Lines 132-139
sub count {
Link Here
|
| 132 |
|
132 |
|
| 133 |
my ( $error, $results, $facets ) = $search->search_compat( |
133 |
my ( $error, $results, $facets ) = $search->search_compat( |
| 134 |
$query, $simple_query, \@sort_by, \@servers, |
134 |
$query, $simple_query, \@sort_by, \@servers, |
| 135 |
$results_per_page, $offset, $branches, $query_type, |
135 |
$results_per_page, $offset, undef, $item_types, |
| 136 |
$scan |
136 |
$query_type, $scan |
| 137 |
) |
137 |
) |
| 138 |
|
138 |
|
| 139 |
A search interface somewhat compatible with L<C4::Search->getRecords>. Anything |
139 |
A search interface somewhat compatible with L<C4::Search->getRecords>. Anything |
|
Lines 144-152
get ignored here, along with some other things (like C<@servers>.)
Link Here
|
| 144 |
|
144 |
|
| 145 |
sub search_compat { |
145 |
sub search_compat { |
| 146 |
my ( |
146 |
my ( |
| 147 |
$self, $query, $simple_query, $sort_by, |
147 |
$self, $query, $simple_query, $sort_by, |
| 148 |
$servers, $results_per_page, $offset, $branches, |
148 |
$servers, $results_per_page, $offset, $branches, |
| 149 |
$query_type, $scan |
149 |
$item_types, $query_type, $scan |
| 150 |
) = @_; |
150 |
) = @_; |
| 151 |
|
151 |
|
| 152 |
if ( $scan ) { |
152 |
if ( $scan ) { |
|
Lines 544-558
sub _aggregation_scan {
Link Here
|
| 544 |
my $count = scalar(@{$results->{aggregations}{$field}{buckets}}); |
544 |
my $count = scalar(@{$results->{aggregations}{$field}{buckets}}); |
| 545 |
for (my $index = $offset; $index - $offset < $results_per_page && $index < $count; $index++) { |
545 |
for (my $index = $offset; $index - $offset < $results_per_page && $index < $count; $index++) { |
| 546 |
my $bucket = $results->{aggregations}{$field}{buckets}->[$index]; |
546 |
my $bucket = $results->{aggregations}{$field}{buckets}->[$index]; |
| 547 |
# Scan values are expressed as 100 a (count) and 245a (term) |
547 |
# Scan values are expressed as: |
|
|
548 |
# - MARC21: 100a (count) and 245a (term) |
| 549 |
# - UNIMARC: 200f (count) and 200a (term) |
| 548 |
my $marc = MARC::Record->new; |
550 |
my $marc = MARC::Record->new; |
| 549 |
$marc->encoding('UTF-8'); |
551 |
$marc->encoding('UTF-8'); |
| 550 |
$marc->append_fields( |
552 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 551 |
MARC::Field->new((100, ' ', ' ', 'a' => $bucket->{doc_count})) |
553 |
$marc->append_fields( |
| 552 |
); |
554 |
MARC::Field->new((200, ' ', ' ', 'f' => $bucket->{doc_count})) |
| 553 |
$marc->append_fields( |
555 |
); |
| 554 |
MARC::Field->new((245, ' ', ' ', 'a' => $bucket->{key})) |
556 |
$marc->append_fields( |
| 555 |
); |
557 |
MARC::Field->new((200, ' ', ' ', 'a' => $bucket->{key})) |
|
|
558 |
); |
| 559 |
} else { |
| 560 |
$marc->append_fields( |
| 561 |
MARC::Field->new((100, ' ', ' ', 'a' => $bucket->{doc_count})) |
| 562 |
); |
| 563 |
$marc->append_fields( |
| 564 |
MARC::Field->new((245, ' ', ' ', 'a' => $bucket->{key})) |
| 565 |
); |
| 566 |
} |
| 556 |
$records[$index] = $marc->as_usmarc(); |
567 |
$records[$index] = $marc->as_usmarc(); |
| 557 |
}; |
568 |
}; |
| 558 |
# consumers of this expect a namespaced result, we provide the default |
569 |
# consumers of this expect a namespaced result, we provide the default |