Gossamer Forum
Home : Products : Links 2.0 : Customization :

Bmxer's codes 'OR operator if AND search fails'

Quote Reply
Bmxer's codes 'OR operator if AND search fails'
Hello

Bmxer gives codes in the following thread :
http://www.gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=L2Cust&Number=41660&page=&view=&sb=&vc=1

It was exactly what that I want,
because the default operator with search is 'AND',
but it will be so cool if there is no result with AND, that there is an automatically search with 'OR'

Bmxer said :

Put it like this instead, in search.cgi where you find
# Word is too common, don't try and sort it, can cause problems.
if (($numhits > 50) and (($grand_total * 0.75) < $numhits)) {
return "Search term is too common.";


put something like this under it
$string = $ENV{'QUERY_STRING'};
$string=~ s/\&bool=\d+//;
if ($numhits == 0) {
if ($in{'bool'} eq 'and') {
print "Location: http://www.yoursearchurlhere/cgi-bin/search.cgi?$string&bool=or\n\n" ;
}
}


SO i've made the following modification in search.cgi file :

# Word is too common, don't try and sort it, can cause problems.
if (($numhits > 50) and (($grand_total * 0.75) < $numhits)) {
return "Search term is too common.";
$string = $ENV{'QUERY_STRING'};
$string=~ s/\&bool=\d+//;
if ($numhits == 0) {
if ($in{'bool'} eq 'and') {
print "http://www.mydomain.com/cgi-bin/links/cgi-bin/search.cgi?$string&bool=or\n\n" ;
}
}
}


But it seems do not work...

Thanks for your help Laugh
Ciao

Quote Reply
Post deleted by Domenic In reply to
Quote Reply
Re: Bmxer's codes 'OR operator if AND search fails' In reply to
Disregard my previous post-----the one that Bmxer posted should work.