Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Search.cgi is different :-(

(Page 2 of 2)
> >
Quote Reply
Re: Search.cgi is different :-( In reply to
michael.. i made a mistake Smile

Code:
($link_hits = $linkdb->query ( { %filter, ww => $ww } ));

to

Code:
($link_hits = $linkdb->query ( { %filter, mh => $mh, nh => $nh, ww => $ww } ));

now it will display the correct links on the second page.. also.. you might want to get rid of the bolded part.. just say you have a field.. the data is 1987 and you use the bolded part.. if you search for 98, 87, 19, 987, 198.. you will get that link.. if you get rid of the bolded.. you have to search for 1987

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
OK then,

I am going to work on the range thingo's, I'll post it here when I come up with a good way of doing it, I can imagine it'll just be a whole lot of if elses though unless I can come up with a 'smart' way of doing it Wink

BTW - What is the bolded part? I can't find it anywhere Smile
Quote Reply
Re: Search.cgi is different :-( In reply to
Code:
, ww => $ww

is the bolded part...

does the admin even have range searches?

it's actually easy to put in a query..

WHERE Price < 50

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
correct me if i'm wrong alex..

range searches..

http://www.url.com/search.cgi?custom=1&space=>50

to search for something with more than 50 mb.. or whatever..

and looking at sub query in dbsql.. i don't think range searches work when searching with a query.. and it doesn't work with keywords either..

something i don't get..

Code:
($opt_r->{$column} =~ /^>(.+)$/) and push (@gt_fields, $1) and next;
($opt_r->{$column} =~ /^<(.+)$/) and push (@lt_fields, $1) and next;

shouldn't this be..

Code:
($opt_r->{$column} =~ /^>.+$/) and push (@gt_fields, $column) and next;
($opt_r->{$column} =~ /^<.+$/) and push (@lt_fields, $column) and next;

cause.. when you go down a bit..

Code:
foreach my $field (@lt_fields) {
$value_q = $DBH->quote($opt_r->{$field});
$where .= qq!
$field <= $value_q $bool!;
}
foreach my $field (@gt_fields) {
$value_q = $DBH->quote($opt_r->{$field});
$where .= qq!
$field >= $value_q $bool!;
}

$field would be equal to 50 (in the example way above) and that would mean you get..

50 >= 50 AND

instead of

space >= 50 AND

?? right?

my signature.. Smile

------------------
Jerry Su
Quote Reply
Re: Search.cgi is different :-( In reply to
Can we get some more specifics on this mod?

I've gone over the instructions above and have discovered that they don't work as posted, so I'm missing some train of thought here.

Here are the pieces that I know that I'm missing.

1. Where do I put this?

if ($in->param('query') &#0124; &#0124; $in->param('custom')) {
#this means no query..
my %filter = ();
foreach my $col (@{$linkdb->{db_cols}}) {
if ($in->param($col)) {
$filter{$col} = $in->param($col);
}
}
$link_hits = $linkdb->query ( { mh => $mh, nh => $nh, filter => \%filter, ww => $ww } );
}

I get a compilation error if I put it in sub main and I get an unblessed reference "query" if I put it in sub search. I can't get beyond that point.

What am I missing.

I also tried Alex's mention of:
if ($in->param('query')) {
&search ($in, $dynamic);
}
elsif ($in->param('custom')) {
.. use second style of searching like admin
}
else {
my $hits = $db->query (&cgi_to_hash($in));

#That caused a compilation error in sub main.

}

else {
&site_html_search_form ( { query => '', db=>$TABLE }, $dynamic );
}

Any body have any ideas what I'm missing?

Peace.

Kyle
Quote Reply
Re: Search.cgi is different :-( In reply to
Jerry,

That range searches is good idea.... I didn't think of using the greater then/less then symbols, cause I am not that familiar with MySQL queries yet....

I think I will be better of trying to get some code to assign it to the right range, cause sometimes I need to use GB's and other times MB's...

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: Search.cgi is different :-( In reply to
Thanks Jerry, I missed this one before.

To get range searches working properly, edit DBSQL.pm and change around line 519 after:

foreach my $column (@{$self->{'db_cols'}}) {

replace the next two lines with:

($opt_r->{$column} =~ /^>(.+)$/) and do { $opt_r->{$column} = $1; push(@gt_fields, $column); next; };
($opt_r->{$column} =~ /^<(.+)$/) and do { $opt_r->{$column} = $1; push(@lt_fields, $column); next; };

To use range searches you either put a > or < at the beginning of the search, or you name your text box ColumnName-gt or ColumnName-lt (i.e. add -gt or -lt for greater then or less then).

Cheers,

Alex
Quote Reply
Re: Search.cgi is different :-( In reply to
Yeah,

I made some changes in there somewhere to get it to work - I am currently working on the keyword feature to work out what the most popular features a webhost could have, by logging how much bandwidth people want etc...

Just get the custom=1 thing going, and once that is working you can get the search working the way you expect it to.

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: Search.cgi is different :-( In reply to
Wow... you've been working hard on this!

Quote Reply
Re: Search.cgi is different :-( In reply to
Hi all,

First of all I would like to thanks all of you for making this thread. I made the changes you suggested so that the search with custom=1 works and it does =).

I would also add that by commenting the line in "search.cgi":
Code:
($in->param('custom') && keys %filter > 0) or &site_html_search_failure ( { error => "Must Set One Parameter.", %in }, $dynamic) and return;

The query search and the custom search work but you need to put them in separate FORM action.

I also want to tell you that I manage to make the range searches work (modification are made in DBSQL.pm).

Replace:
Code:
my @search_fields = (); my @lt_fields = (); my @gt_fields = (); my $search_index = '';
with:
Code:
my @search_fields = (); my @lt_fields = (); my @gt_fields = (); my @gt_lt_fields = (); my $search_index = '';

then after:
Code:
foreach my $column (@{$self->{'db_cols'}}) {

add these lines (the 2 last where already there if you read and followed the thread):
Code:
($opt_r->{$column} =~ /^\[(.+)\]$/) and do { $opt_r->{"$column"} = $1; print "$column - $opt_r->{$column}<br>"; push(@gt_lt_fields, $column); next; };
($opt_r->{$column} =~ /^>(.+)$/) and do { $opt_r->{"$column"} = $1; push(@gt_fields, $column); next; };
($opt_r->{$column} =~ /^<(.+)$/) and do { $opt_r->{"$column"} = $1; push(@lt_fields, $column); next; };

then replace:
Code:
if (!@search_fields and !@gt_fields and !@lt_fields) {

with:
Code:
if (!@search_fields and !@gt_fields and !@lt_fields and !@gt_lt_fields) {

add before:
Code:
foreach my $field (@lt_fields) {

these lines:
Code:
foreach my $field (@gt_lt_fields) {
$value_q = $DBH->quote($opt_r->{$field});
$value_q =~ /^'(.+)-(.+)'$/;
$where .= qq!
($field >= $1 AND $field <= $2) $bool!;
}

and to have a correct range search you must use number not string so after:
Code:
foreach my $field (@lt_fields) {
$value_q = $DBH->quote($opt_r->{$field});
and
Code:
foreach my $field (@gt_fields) {
$value_q = $DBH->quote($opt_r->{$field});

add those 2 lines:
Code:
$value_q =~ /^'(.+)'$/;
$value_q = $1;

With there changes you now can range search =)

for greater than: ?variable=>10
for lower than: ?variable=<10
for a certain rage: ?variable=[0-10]

...

Any question?



------------------
Dann Cohen
Toxik Technologies Inc. - Montreal, Quebec, Canada
www.toxik.com
Quote Reply
Re: Search.cgi is different :-( In reply to
when i do search.cgi?query=something&isNew=Yes it only display 1 result but when i use the search-ni.cgi it dislpay all the results,

i try to re-index with some weight on the isNew field and it dosent work..

any ideas of what can i do?

tnks
fernandot


Alex: Great improvement on the site !! = )


Quote Reply
Re: Search.cgi is different :-( In reply to
The search-ni.cgi is a different beastie. It's not the same as search.cgi, so what works for search.cgi (as you have found) doesn't work with the non-indexed search.

You'll have to wait for Alex to answer that one. It may be different in the next release as well.



> >