single field search mapping to fill text indexes
[Biblio-Z3950.git] / server.pl
index 0571e9a..91d45a1 100755 (executable)
--- a/server.pl
+++ b/server.pl
@@ -10,6 +10,9 @@ use Data::Dumper;
 use Aleph;
 use GoogleBooks;
 use vuFind;
+use DPLA;
+use AlephTR;
+use CROSBI;
 
 use Encode;
 
@@ -21,6 +24,11 @@ my $databases = {
        'ZAG01'  => 'Aleph',
        'GOOGLEBOOKS' => 'GoogleBooks',
        'HATHITRUST' => 'vuFind',
+       'DPLA'   => 'DPLA',
+       'MKUTUP' => 'AlephTR',
+       'CROSBI' => 'CROSBI',
+       'CROSBI-CASOPIS' => 'CROSBI',
+       'CROSBI-PREPRINT' => 'CROSBI',
 };
 
 my $max_records = 10; # XXX configure this
@@ -62,7 +70,7 @@ diag "SearchHandle ",Dumper($self);
 diag "using $module for $database ", Dumper( $from );
 
        eval { $query = $rpn->{query}->render( $from->usemap ); };
-       warn "ERROR: $@" if $@;
+       warn "ERROR: ", Dumper($@) if $@;
     if ( $@ && ref($@) ) {    ## Did someone/something report any errors?
         $self->{ERR_CODE} = $@->{errcode};
         $self->{ERR_STR}  = $@->{errstr};
@@ -147,7 +155,9 @@ sub FetchHandle {
        my $from = $rs->{from} || die "no from?";
        # fetch records up to offset
        while(  $#{ $rs->{results} } < $offset ) {
-               push @{ $rs->{results} }, $from->next_marc;
+               my $marc = $from->next_marc;
+               last if ! $marc; # abort results
+               push @{ $rs->{results} }, $marc;
                warn "# rs result ", $#{ $rs->{results} },"\n";
        }
 
@@ -264,7 +274,8 @@ warn "# usemap ", dump($usemap);
         }
     }
     if ( defined( $attributes->{5} ) ) {                ## No truncation
-        die { errcode => 113, errstr => 5 };
+#      die { errcode => 113, errstr => 5 };
+       warn "# truncation is ignored";
     }
     my $comp = $attributes->{6};
     if ($prefix) {
@@ -279,7 +290,7 @@ warn "# usemap ", dump($usemap);
                warn "# using custom prefix_term query";
                $q = $usemap->{prefix_term}->( $prefix, $self->{term} );
        } else {
-       $q = $prefix . $self->{term} . '*';
+               $q = $prefix . $self->{term} . '*';
        }
        print "# q: $q\n";
        return $q;