Lines 358-370
foreach my $sort (@sort_by) {
Link Here
|
358 |
} |
358 |
} |
359 |
$template->param('sort_by' => $sort_by[0]); |
359 |
$template->param('sort_by' => $sort_by[0]); |
360 |
|
360 |
|
361 |
# Use the servers defined, or just search our local catalog(default) |
|
|
362 |
my @servers = $cgi->multi_param('server'); |
363 |
unless (@servers) { |
364 |
#FIXME: this should be handled using Context.pm |
365 |
@servers = ("biblioserver"); |
366 |
# @servers = C4::Context->config("biblioserver"); |
367 |
} |
368 |
# operators include boolean and proximity operators and are used |
361 |
# operators include boolean and proximity operators and are used |
369 |
# to evaluate multiple operands |
362 |
# to evaluate multiple operands |
370 |
my @operators = map uri_unescape($_), $cgi->multi_param('op'); |
363 |
my @operators = map uri_unescape($_), $cgi->multi_param('op'); |
Lines 523-532
my $total = 0; # the total results for the whole set
Link Here
|
523 |
my $facets; # this object stores the faceted results that display on the left-hand of the results page |
516 |
my $facets; # this object stores the faceted results that display on the left-hand of the results page |
524 |
my $results_hashref; |
517 |
my $results_hashref; |
525 |
|
518 |
|
|
|
519 |
my $server = 'biblioserver'; |
526 |
eval { |
520 |
eval { |
527 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; |
521 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; |
528 |
( $error, $results_hashref, $facets ) = $searcher->search_compat( |
522 |
( $error, $results_hashref, $facets ) = $searcher->search_compat( |
529 |
$query, $simple_query, \@sort_by, \@servers, |
523 |
$query, $simple_query, \@sort_by, [$server], |
530 |
$results_per_page, $offset, undef, $itemtypes, |
524 |
$results_per_page, $offset, undef, $itemtypes, |
531 |
$query_type, $scan |
525 |
$query_type, $scan |
532 |
); |
526 |
); |
Lines 541-552
if ($@ || $error) {
Link Here
|
541 |
exit; |
535 |
exit; |
542 |
} |
536 |
} |
543 |
|
537 |
|
544 |
# At this point, each server has given us a result set |
|
|
545 |
# now we build that set for template display |
546 |
my @sup_results_array; |
547 |
for (my $i=0;$i<@servers;$i++) { |
548 |
my $server = $servers[$i]; |
549 |
if ($server =~/biblioserver/) { # this is the local bibliographic server |
550 |
my $hits = $results_hashref->{$server}->{"hits"} // 0; |
538 |
my $hits = $results_hashref->{$server}->{"hits"} // 0; |
551 |
if ( $hits == 0 && $basic_search ){ |
539 |
if ( $hits == 0 && $basic_search ){ |
552 |
$operands[0] = '"'.$operands[0].'"'; #quote it |
540 |
$operands[0] = '"'.$operands[0].'"'; #quote it |
Lines 562-575
for (my $i=0;$i<@servers;$i++) {
Link Here
|
562 |
eval { |
550 |
eval { |
563 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; |
551 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; |
564 |
( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat( |
552 |
( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat( |
565 |
$query, $simple_query, \@sort_by, ['biblioserver'], |
553 |
$query, $simple_query, \@sort_by, [$server], |
566 |
$results_per_page, $offset, undef, $itemtypes, |
554 |
$results_per_page, $offset, undef, $itemtypes, |
567 |
$query_type, $scan |
555 |
$query_type, $scan |
568 |
); |
556 |
); |
569 |
}; |
557 |
}; |
570 |
my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0; |
558 |
my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0; |
571 |
if ( $quoted_hits ){ |
559 |
if ( $quoted_hits ){ |
572 |
$results_hashref->{'biblioserver'} = $quoted_results_hashref->{'biblioserver'}; |
560 |
$results_hashref->{$server} = $quoted_results_hashref->{$server}; |
573 |
$hits = $quoted_hits; |
561 |
$hits = $quoted_hits; |
574 |
} |
562 |
} |
575 |
} |
563 |
} |
Lines 689-718
for (my $i=0;$i<@servers;$i++) {
Link Here
|
689 |
$template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc); |
677 |
$template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc); |
690 |
} |
678 |
} |
691 |
|
679 |
|
692 |
} # end of the if local |
|
|
693 |
|
694 |
# asynchronously search the authority server |
695 |
elsif ($server =~/authorityserver/) { # this is the local authority server |
696 |
my @inner_sup_results_array; |
697 |
for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) { |
698 |
my $marc_record_object = C4::Search::new_record_from_zebra( |
699 |
'authorityserver', |
700 |
$sup_record |
701 |
); |
702 |
# warn "Authority Found: ".$marc_record_object->as_formatted(); |
703 |
push @inner_sup_results_array, { |
704 |
'title' => $marc_record_object->field(100)->subfield('a'), |
705 |
'link' => "&idx=an&q=".$marc_record_object->field('001')->as_string(), |
706 |
}; |
707 |
} |
708 |
push @sup_results_array, { servername => $server, |
709 |
inner_sup_results_loop => \@inner_sup_results_array} if @inner_sup_results_array; |
710 |
} |
711 |
# FIXME: can add support for other targets as needed here |
712 |
$template->param( outer_sup_results_loop => \@sup_results_array); |
713 |
} #/end of the for loop |
714 |
#$template->param(FEDERATED_RESULTS => \@results_array); |
715 |
|
716 |
my $gotonumber = $cgi->param('gotoNumber'); |
680 |
my $gotonumber = $cgi->param('gotoNumber'); |
717 |
if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) { |
681 |
if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) { |
718 |
$template->{'VARS'}->{'gotoNumber'} = $gotonumber; |
682 |
$template->{'VARS'}->{'gotoNumber'} = $gotonumber; |