my $query;
$query= "an=".$authid;
my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
- return ($result);
+ if ($err) {
+ warn "Error: $err from search $query";
+ $result = 0;
+ }
+
+ return $result;
}
}
}
my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
# there is at least 1 result => return the 1st one
- if (@$results>0) {
+ if (!defined $error && @{$results} ) {
my $marcrecord = MARC::File::USMARC::decode($results->[0]);
return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
}
use C4::Context;
use C4::Heading::MARC21;
use C4::Search;
+use Carp;
our $VERSION = 3.00;
my $query = qq(Match-heading,do-not-truncate,ext="$self->{'search_form'}");
$query .= $self->_query_limiters();
my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
+ if (defined $error) {
+ carp "Error:$error from search $query";
+ }
return $results;
}
my $query = "Match-heading-see-from,do-not-truncate,ext='$self->{'search_form'}'";
$query .= $self->_query_limiters();
my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
+ if (defined $error) {
+ carp "Error:$error from search $query";
+ }
return $results;
}
# FIXME only searching biblio index at the moment
my ($error, $searchresults, $total_hits) = SimpleSearch($query, 0, $max_matches);
- warn "search failed ($query) $error" if $error;
- foreach my $matched (@$searchresults) {
- $matches{$matched} += $matchpoint->{'score'};
+ if (defined $error ) {
+ warn "search failed ($query) $error";
+ } else {
+ foreach my $matched (@{$searchresults}) {
+ $matches{$matched} += $matchpoint->{'score'};
+ }
}
}
my @results;
-if ($marcresults) {
- foreach my $result ( @{$marcresults} ) {
- my $marcrecord = MARC::File::USMARC::decode( $result );
- my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
+foreach my $result ( @{$marcresults} ) {
+ my $marcrecord = MARC::File::USMARC::decode( $result );
+ my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
- $biblio->{booksellerid} = $booksellerid;
- push @results, $biblio;
+ $biblio->{booksellerid} = $booksellerid;
+ push @results, $biblio;
- }
}
+
$template->param(
basketno => $basketno,
booksellerid => $bookseller->{'id'},
$query= "an=".$authority->{'authid'};
# search for biblios mapped
my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
+ if (defined $err) {
+ $used = 0;
+ }
if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){
print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n);
}
warn "BIBLIOADDSAUTHORITIES: $error";
return (0,0) ;
}
- if ($results && scalar(@$results)==1) {
+ if ( @{$results} == 1) {
my $marcrecord = MARC::File::USMARC::decode($results->[0]);
$field->add_subfields('9'=>$marcrecord->field('001')->data);
$countlinked++;
- } elsif (scalar(@$results)>1) {
+ } elsif (@{$results} > 1) {
#More than One result
#This can comes out of a lack of a subfield.
# my $marcrecord = MARC::File::USMARC::decode($results->[0]);
# $record->field($data->{tagfield})->add_subfields('9'=>$marcrecord->field('001')->data);
- $countlinked++;
+ $countlinked++;
} else {
#There are no results, build authority record, add it to Authorities, get authid and add it to 9
###NOTICE : This is only valid if a subfield is linked to one and only one authtypecode
# format output
# SimpleSearch() give the results per page we want, so 0 offet here
- my $total = scalar @$marcresults;
- my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, @$marcresults );
+ my $total = @{$marcresults};
+ my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, @{$marcresults} );
$template->param(
total => $total_hits,
query => $query,
my $orderby;
$search = 'kw,wrdl='.$search.' and mc-itemtype='.$itype if $itype;
my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
- my $total = scalar(@$results);
+ if (defined $errors ) {
+ $results = [];
+ }
+ my $total = @{$results};
# warn " biblio count : ".$total;
( $error, $marcresults, $total_hits ) =
SimpleSearch( $ccl_query, $offset, $resultsperpage );
- if (scalar($marcresults) > 0) {
- $show_results = scalar @$marcresults;
+ if (!defined $error && @{$marcresults} ) {
+ $show_results = @{$marcresults};
}
else {
$debug and warn "ERROR label-item-search: no results from SimpleSearch";
my ($error, $results,$totalhits)=C4::Search::SimpleSearch( $query, 0, 3, [$server] );
die "unable to search the database for duplicates : $error" if (defined $error);
#warn "$query $server : $totalhits";
- if ($results && scalar(@$results)==1){
+ if ( @{$results} == 1 ){
my $marcrecord = MARC::File::USMARC::decode($results->[0]);
$id=GetRecordId($marcrecord,$tagid,$subfieldid);
}
- elsif ($results && scalar(@$results)>1){
- $debug && warn "more than one match for $query";
+ elsif ( @{$results} > 1){
+ $debug && warn "more than one match for $query";
}
else {
- $debug && warn "nomatch for $query";
+ $debug && warn "nomatch for $query";
}
}
my $originalid;
$query= "an=".$data->{'authid'};
# search for biblios mapped
my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
+ if (defined $err) {
+ warn "error: $err on search $query\n";
+ next;
+ }
print ".";
print "$counter\n" unless $counter++ % 100;
# if found, delete, otherwise, just count
$self->reindex_marc();
my $query = 'Finn Test';
- my ( $error, $results ) = SimpleSearch( $query );
- if ( $param{'count'} <= scalar( @$results ) ) {
+ my ( $error, $results, undef ) = SimpleSearch( $query );
+ if ( !defined $error && $param{'count'} <= @{$results} ) {
pass( "found all $param{'count'} titles" );
} else {
fail( "we never found all $param{'count'} titles" );