Skip to main content.
home | support | download

Back to List Archive

Re: [swish-e] Swish 2.4.5 working, SWISH::API seems to be working but isn't

From: Peter Karman <peter(at)not-real.peknet.com>
Date: Mon Feb 19 2007 - 02:04:54 GMT
Bernard T. Higonnet scribbled on 2/17/07 4:39 PM:
> Hello,
> 
> I seem to have installed everything so it's working. I have indexed a web site 
> and when I search it using swish-e on the command line it gets the right 
> results.
> 
> When I try to use SWISH::API so that a browser can search my web site, I don't 
> get very far.
> 
> SWISH::API seems to be working. What that means is that it does simple things 
> without complaining, has been known to write error messages (e.g. when it 
> couldn't find the index file on the first try). Here is the code I am using
> 
> ========================================
> my $myindex="/tmp/index.swish-e";
> my $swish = SWISH::API->new($myindex);
> print header(), start_html();
> my $badmsg = $swish->error_string;
> print "hoo $badmsg<br>";
> $badmsg = $swish->last_error_msg;
> print "haa $badmsg<br>";
> my $search = $swish->new_search_object;
> my $results = $search->execute( "Bonnieux" );
> if ($swish->Error) {$badmsg = $swish->error_string;print "queryhoo 
> $badmsg<br>";
>     $badmsg = $swish->last_error_msg;print "queryhaa $badmsg<br>";}
> my $hits = $results->hits;
> print "Found ", $results->hits, " hits<br>";
> 
> 
> The code above yields this:
> 
> hoo
> haa
> queryhoo
> queryhaa
> Found -4629728351404162355 hits
> ===================================================


the output indicates there was an error but you're not getting the error string.

Try this example, lifted from the SWISH::API SYNOPSIS:

use SWISH::API;
my $myindex = shift @ARGV;
my $swish   = SWISH::API->new($myindex);
my $search  = $swish->new_search_object;
my $results = $search->execute(shift @ARGV);
$swish->abort_last_error if $swish->error;
my $hits = $results->hits;
print "Found $hits hits\n";


and call it like:

  perl scriptname path/to/index.swish-e query


-- 
Peter Karman  .  http://peknet.com/  .  peter(at)not-real.peknet.com
_______________________________________________
Users mailing list
Users@lists.swish-e.org
http://lists.swish-e.org/listinfo/users
Received on Sun Feb 18 21:03:05 2007