Skip to main content.
home | support | download

Back to List Archive

(patch) select_indexes and brief don't mix

From: Dan Debertin <debertin(at)not-real.umn.edu>
Date: Wed Jul 30 2003 - 14:29:01 GMT
In swish.cgi, if swish_index is an arrayref and the brief search is
used, there's no opportunity to select the index and swish-e tries to
use the system default. This patch adds a 'default_index' parameter to
select_indexes, which is used if no index is selected.

--- /usr/local/lib/swish-e/swish.cgi    2003-07-28 11:54:00.610019000 -0500
+++ swish.cgi   2003-07-30 09:01:57.950004000 -0500
@@ -390,6 +390,7 @@
             # labels must match up one-to-one with elements in "swish_index"
             labels  => [ 'Main Index', 'Other Index', qw/ two three four/ ],  
             description => 'Select Site: ',
+                       default_index => '',  
         },
 
 
@@ -1362,12 +1385,19 @@
     
     # Set the index file - first check for options
     
-    if ( $self->config('select_indexes') && ref $self->config('swish_index') eq 'ARRAY'  ) {
+       my $si = $self->config('select_indexes');
+    if ( $si && ref $self->config('swish_index') eq 'ARRAY'  ) {
 
         my @choices = $q->param('si');
         if ( !@choices ) {
-            $self->errstr('Please select a source to search');
-            return;
+                       if ( $si->{'default_index'} ) {
+                               $self->swish_command('-f', $si->{'default_index'});
+                               return 1;
+                       }
+                       else {
+               $self->errstr('Please select a source to search');
+               return;
+                       }
         }
 
         my @indexes = @{$self->config('swish_index')};

Dan
-- 
Dan Debertin                             Unix Systems Admin
Diehl Hall #203B			 University of Minnesota
(612)626-6468				 Bio-Medical Library
debertin@umn.edu
Received on Wed Jul 30 14:31:05 2003