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

Search.cgi is different :-(

(Page 1 of 2)
> >
Quote Reply
Search.cgi is different :-(
Hi,

I thought that the basic things from Links SQL and Links 2.0 were the same, but the search.cgi files work differently, and this is a real bad thing for me right now, which is what most of my site will run off Frown

With Links 2.0, if for example I had a field called space and one of them had a value of 30MB I could use this.

search.cgi?space=30MB

and I would get a result.

With SQL if I try one (that I know exists)

search.cgi?controlpanel=Yes

I just get redirected to the search form Frown

http://www.webhostarea.com/cgi-bin/hosts/search.cgi?controlpanel=Yes

Is the full thing, I haven't made the actual form yet, I have been typing in the URL's.. please advice, this is sorta urgent.

Thanks in advance BTW (Please don't say mod the code, I would have done that if I could, but after looking at the search.cgi file gave up on this).

------------------
Michael Bray
....
Review your webhost, or find a new one at http://www.webhostarea.com


Quote Reply
Re: Search.cgi is different :-( In reply to
It does support what you ask (somewhat). You must always pass in query=something, but can filter the results. i.e. to search for a link that matches 'somestring' and is new, you could do:

search.cgi?query=something&isNew=Yes

Hope this helps,

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

To clear up some fine points:

Code:
search.cgi?query=something&isNew=Yes

This means, that the search.cgi looks for a passed parameter query to act on (the same way jump.cgi looks for ID).

You can add options to that query, using the standard "&" notation and form input.

Do we need to write the utils to parse that out?? Or is it parsed out for us and put into the in-> array?

We then only need to add a line to the top of the file:

Code:
($in->param('passedValue')) ? ($myValue = 0) : ($myValue = 1);


It looks like it would work, but we already found out that search does things its own way. Smile






------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/







Quote Reply
Re: Search.cgi is different :-( In reply to
could you do

query=*

? Smile

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
 
Quote:
Do we need to write the utils to parse that out?? Or is it parsed out for us and put into the in-> array?

All form input is automagically put into $in and can be acccessed normally. Also, search.cgi recognizes if you pass in a field_name=somevalue and adds that to the filter list to filter the results from.

Quote:
could you do query=*

No, that would make things to easy. Wink Unfortunately the way the filter works, is it needs a result set to work against, and it would be very impractical to grab the whole list of links first. You could hack this in though. If you do something like:

search.cgi?custom=1&field_name=somevalue

then in search.cgi:

if ($in->param('custom')) {
$hits = $db->query ( { field_name = $in->param('field_name') } );
...
}

details left to the reader, but I hope you get the idea.

Cheers,

Alex

Quote Reply
Re: Search.cgi is different :-( In reply to
Great -- So it works the way you'd expect Smile

Once the holidays are over, I think great things are going to be shown off by the various sites that have started to get the modifications working.

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/







Quote Reply
Re: Search.cgi is different :-( In reply to
that means he has to turn off is_db_indexed..

or at least mod query to say either on or off.. just like with substring..

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

I was writing a message joking about you ignoring me when I got the message saying you had responded. Thanks mate, appreciated!!!!
Quote Reply
Re: Search.cgi is different :-( In reply to
alex..

do you really have to check query twice??

first you check it in sub main.. then in sub search..

can't you eliminate this code..

Code:
$query or &site_html_search_failure ( { error => "No search term entered.", %in }, $dynamic) and return;

and michael.. i change my mind about that code Smile it wouldn't work anywhere in search.cgi but it was to let you know about the filter thing..

and .. please try

http://www.url.com/...amp;controlpanel=Yes

i don't see why that wouldn't work and in the admin it allows ID=*

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
Jerry, you get this error if you try it..

Quote:
Ignored the following terms

* - Lacks alphnumerics

I am gonna have a look through search.cgi see if I can delete the ckecking for this...
Quote Reply
Re: Search.cgi is different :-( In reply to
nope.. it's DBSQL.pm

i just noticed it.. it doesn't allow the query to be * but allows for fields to be *..

grr... Smile

ok.. you're gonna have to go another way..

change

Code:
if ($in->param('query')) {

to

Code:
if ($in->param('query') || $in->param('custom')) {

delete this line

Code:
$query or &site_html_search_failure ( { error => "No search term entered.", %in }, $dynamic) and return;

under:

Code:
foreach my $col (@{$linkdb->{db_cols}}) {
if ($in->param($col)) {
$filter{$col} = $in->param($col);
}
}

add..

Code:
($in->param('custom') && keys %filter > 0) or
&site_html_search_failure ( { error => "Must Set One Parameter.", %in }, $dynamic) and return;

now try it.. if it gives some error about query..

change this line:

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

to

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

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
and DUH..

http://www.url.com/...amp;controlpanel=Yes

if you don't respond.. i don't sleep.. Smile

i'm gonna have to readjust my sleeping and waking up times back to normal some day..

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
that wasn't a promise you know.. Smile

anyways.. i'll check back on you tommorrow..

probably late after noon when i wake up..

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
Will test in 30 mins, in the middle of a movie, just checking up while the ads are one Smile
Quote Reply
Re: Search.cgi is different :-( In reply to
OK then, no error messages, but I have made it with links the controlpanel attribute has to be either Yes or No, and either way I don't get any results Frown

I'll work on this while you guys in the northen hemisphere sleep :P
Quote Reply
Re: Search.cgi is different :-( In reply to
Hmmm.. It doesn't work when I search for ID=3 etc - Is there a variable somewhere like in Links 2.0 where I have to choose the fields to be searched? Thanks!
Quote Reply
Re: Search.cgi is different :-( In reply to
In your .def file, did you set the weight of the ID field to '1' ??

The search.cgi only searches fields that are indexed, and only fields with a weight>1 are indexed.
Quote Reply
Re: Search.cgi is different :-( In reply to
Could someone please explain how I would place that for more then one object.. example.. would I place it like...

Code:
if ($in->param('custom')) {
$hits = $db->query ( { field_name = $in->param('field_name') } );
if ($in->param('custom')) {
$hits = $db->query ( { field_name = $in->param('field_name2') } );

}

Also, do I place in in sub search, or by itself?

THANKS!
Quote Reply
Re: Search.cgi is different :-( In reply to
once the holidays are over.. i have to study for finals Frown..

also.. pugdog.. will you please email me.. i can't find your email anywhere..

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
oh. i totally ignored you michael Smile

no.. not foreach..

Code:
if ($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 } );
}

once again.. alex can't he just say.. ?query=*&field=links

or something..
Quote Reply
Re: Search.cgi is different :-( In reply to
Ok, there are two modes of searching: indexed and normal. To search with the search index, you should use:

$db->query ( { index => 'some phrase', filter => \%filter } );

This allows you to use altavista style searching with +, - , "phrases", etc. The search index requires something to be entered in the index part, and the filters only work on filtering the result of your search. Also, the search index does not allow you to search on *.

The second method of searching, is by just passing in field names to query. This is how the admin works:

$db->query ( { Title => "foo", Description => "bar" } );

With this, you can use * to match all fields, but you can't use altavista style searching. So, if you don't want to use the search index, and just search on a field like the admin, you have to use this second search method. That's why you want to do something like:

if ($in->param('query')) {
.. do search as normal with indexed search
}
elsif ($in->param('custom')) {
.. use second style of searching like admin
}
else {
.. oops, no search terms entered. display form.
}

The second method would look just like:

my $hits = $db->query (&cgi_to_hash($in));

and assuming you have passed in Field_name=Somevalue to the form, it will do a search just like the admin.

I hope this helps,

Alex
Quote Reply
Re: Search.cgi is different :-( In reply to
eck.. so he has to make another sub..

he can still use filter though.. but not the same way.. more like

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

no substring..

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
wait a sec.. michael... follow my instructions above again.. do everything excecpt the last one..

do this instead..

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

jerry
Quote Reply
Re: Search.cgi is different :-( In reply to
It works! Thanks Jerry, Alex and Pugdog!

http://www.webhostarea.com/cgi-bin/hosts/search.cgi?custom=1&ID=2

Now I just need to fix up the templates so you know what everything is :P

Quote Reply
Re: Search.cgi is different :-( In reply to
wow.. Smile

that "might" be useful for me.. tell me if you can ever get the range searches to work.. like < 50 megs.. i need to do something like that except with price Smile

thanks alex for the clues.. i bet you knew how to do it since the beginning.. helping us learn or something? Wink

jerry
> >