Lines 418-424
sub getRecords {
Link Here
|
418 |
for ( my $j = $offset ; $j < $times ; $j++ ) { |
418 |
for ( my $j = $offset ; $j < $times ; $j++ ) { |
419 |
my $records_hash; |
419 |
my $records_hash; |
420 |
my $record; |
420 |
my $record; |
421 |
my $facet_record; |
|
|
422 |
|
421 |
|
423 |
## Check if it's an index scan |
422 |
## Check if it's an index scan |
424 |
if ($scan) { |
423 |
if ($scan) { |
Lines 451-483
sub getRecords {
Link Here
|
451 |
|
450 |
|
452 |
# warn "RECORD $j:".$record; |
451 |
# warn "RECORD $j:".$record; |
453 |
$results_hash->{'RECORDS'}[$j] = $record; |
452 |
$results_hash->{'RECORDS'}[$j] = $record; |
454 |
|
|
|
455 |
# Fill the facets while we're looping, but only for the biblioserver |
456 |
$facet_record = MARC::Record->new_from_usmarc($record) |
457 |
if $servers[ $i - 1 ] =~ /biblioserver/; |
458 |
|
459 |
#warn $servers[$i-1]."\n".$record; #.$facet_record->title(); |
460 |
if ($facet_record) { |
461 |
for ( my $k = 0 ; $k <= @$facets ; $k++ ) { |
462 |
($facets->[$k]) or next; |
463 |
my @fields = map {$facet_record->field($_)} @{$facets->[$k]->{'tags'}} ; |
464 |
for my $field (@fields) { |
465 |
my @subfields = $field->subfields(); |
466 |
for my $subfield (@subfields) { |
467 |
my ( $code, $data ) = @$subfield; |
468 |
($code eq $facets->[$k]->{'subfield'}) or next; |
469 |
$facets_counter->{ $facets->[$k]->{'link_value'} }->{$data}++; |
470 |
} |
471 |
} |
472 |
$facets_info->{ $facets->[$k]->{'link_value'} }->{'label_value'} = |
473 |
$facets->[$k]->{'label_value'}; |
474 |
$facets_info->{ $facets->[$k]->{'link_value'} }->{'expanded'} = |
475 |
$facets->[$k]->{'expanded'}; |
476 |
} |
477 |
} |
478 |
} |
453 |
} |
|
|
454 |
|
479 |
} |
455 |
} |
480 |
$results_hashref->{ $servers[ $i - 1 ] } = $results_hash; |
456 |
$results_hashref->{ $servers[ $i - 1 ] } = $results_hash; |
|
|
457 |
|
458 |
# Fill the facets while we're looping, but only for the biblioserver and not for a scan |
459 |
if ( !$scan && $servers[ $i - 1 ] =~ /biblioserver/ ) { |
460 |
|
461 |
my $jmax = $size; |
462 |
if ( $jmax > 500 ) { |
463 |
$jmax = 500; # limit to 500 first records |
464 |
} |
465 |
|
466 |
for ( my $k = 0 ; $k <= @$facets ; $k++ ) { |
467 |
($facets->[$k]) or next; |
468 |
my @fcodes = @{$facets->[$k]->{'tags'}}; |
469 |
my $sfcode = $facets->[$k]->{'subfield'}; |
470 |
|
471 |
for ( my $j = 0 ; $j < $jmax ; $j++ ) { |
472 |
my $render_record = $results[ $i - 1 ]->record($j)->render(); |
473 |
my @used_datas = (); |
474 |
|
475 |
foreach my $fcode (@fcodes) { |
476 |
|
477 |
# avoid first line |
478 |
my $field_pattern = '\n'.$fcode.' ([^\n]+)'; |
479 |
my @field_tokens = ( $render_record =~ /$field_pattern/g ) ; |
480 |
|
481 |
foreach my $field_token (@field_tokens) { |
482 |
my $subfield_pattern = '\$'.$sfcode.' ([^\$]+)'; |
483 |
my @subfield_values = ( $field_token =~ /$subfield_pattern/g ); |
484 |
|
485 |
foreach my $subfield_value (@subfield_values) { |
486 |
|
487 |
my $data = $subfield_value; |
488 |
$data =~ s/^\s+//; # trim left |
489 |
$data =~ s/\s+$//; # trim right |
490 |
|
491 |
unless ( $data ~~ @used_datas ) { |
492 |
$facets_counter->{ $facets->[$k]->{'link_value'} }->{$data}++; |
493 |
push @used_datas, $data; |
494 |
} |
495 |
} # subfields |
496 |
} # fields |
497 |
} # field codes |
498 |
} # records |
499 |
|
500 |
$facets_info->{ $facets->[$k]->{'link_value'} }->{'label_value'} = $facets->[$k]->{'label_value'}; |
501 |
$facets_info->{ $facets->[$k]->{'link_value'} }->{'expanded'} = $facets->[$k]->{'expanded'}; |
502 |
} # facets |
503 |
} |
504 |
# End PROGILONE |
481 |
} |
505 |
} |
482 |
|
506 |
|
483 |
# warn "connection ", $i-1, ": $size hits"; |
507 |
# warn "connection ", $i-1, ": $size hits"; |
484 |
- |
|
|