Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Suggest query (as in Google Suggest)

(Page 1 of 3)
> >
Quote Reply
Suggest query (as in Google Suggest)
Google has a put up a new toy called "Google Suggest", which you can try out at:
http://www.google.com/...complete=1&hl=en

I just created a small mockup of the same feature for Links SQL (in conjunction with the SearchLogger plugin):
http://www.iyengar-yoga.com/livesearch.html

The CSS and the Javascript is still far from perfect, but you'll get the general idea.

If people are interested, i could make a plugin out of this....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Cool!!

I might have an interest in this.

mgeyman
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Cool

I'd be interested in the plugin!

John
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
That is great
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
I decided not to write a plugin, but simply post all the relevant files here. It works, but the CSS is not perfect yet. If there are any CSS gurus out there, how can make it more Google like, I'd be happy to know!

The LiveSearch feature makes use of the SearchLogger plugin to generate the list, so you need to have this plugin installed, and it should contain a reasonable number of entries for the LiveSearch feature to make sense.

xhtml code
http://www.iyengar-yoga.com/livesearch.html

JavaScript code
http://www.iyengar-yoga.com/inc/livesearch.js

CSS stylesheet
http://www.iyengar-yoga.com/inc/livesearch.css

Perl Code
Code:
#!/usr/bin/perl

# +----------------------------------------------------------------------+
# | Copyright (c) 2004 Iyengar Yoga Resources |
# +----------------------------------------------------------------------+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
# | you may not use this file except in compliance with the License. |
# | You may obtain a copy of the License at |
# | http://www.apache.org/licenses/LICENSE-2.0 |
# | Unless required by applicable law or agreed to in writing, software |
# | distributed under the License is distributed on an "AS IS" BASIS, |
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
# | implied. See the License for the specific language governing |
# | permissions and limitations under the License. |
# +----------------------------------------------------------------------+
# | Author: yogi <info@iyengar-yoga.com> |
# +----------------------------------------------------------------------+

use strict;
use lib '/path/to/links/admin';
use Links qw/$CFG $DB $IN/;

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/path/to/links/admin');

main();

sub main {
my $t = $DB->table('SearchLog');
$t->select_options('ORDER by HitCount DESC', 'LIMIT 10');
my $q = $IN->param('query');
my $cond = GT::SQL::Condition->new( 'Term', 'LIKE', "$q%");
my $sth = $t->select($cond);
my $base = 'http://www.iyengar-yoga.com/perl/directory/search.cgi?query';
print "Content-Type: text/xml\n\n";
if ($t->hits) {
print qq|<ul class="LSRes">|;
while (my $result = $sth->fetchrow_hashref) {
print qq|<li class="LSRow" onmouseover="liveSearchHover(this)" onclick="liveSearchClicked(this)"><a href="$base=$result->{Term}" name="$result->{Term}">$result->{Term}</a> <span style="color:green;overflow:hidden;">$result->{Results} results</span></li>\n|;
}
print qq|</ul>|;
}
}

Background infos on the method used, plus maybe some tips for installation:
http://blog4.bitflux.ch/wiki/LiveSearch

Enjoy!

Ivan
-----
Iyengar Yoga Resources / GT Plugins

Last edited by:

yogi: Mar 9, 2005, 3:45 AM
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
yogi,

I must have missed something. Where does the perl code (you posted above) reside? Is that part of another file?

Thanks a lot.

mgeyman
Quote Reply
Re: [mgeyman] Suggest query (as in Google Suggest) In reply to
The perl script is called from within the JavaScript code. You need to change the javascript according to your needs.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Sorry, yogi, please bear with me, I'm not quite as technical - where or on which line in the livesearch.js file do you point to the file containing the perl script?


Thanks a lot.

mgeyman
Quote Reply
Re: [mgeyman] Suggest query (as in Google Suggest) In reply to
In the js file, look for the line containing
Code:
http://www.iyengar-yoga.com/perl/directory/livesearch.cgi
and replace this with the path to your livesearch.cgi file (i.e. the one posted above, which you saved somewhere on your server).

I hope this helps.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Well, I must be getting closer to getting this to work as I'm now getting this Internal Server Error message in the gray box to the right of the form box on livesearch.html.

mgeyman
Quote Reply
Re: [mgeyman] Suggest query (as in Google Suggest) In reply to
Hi,
You may be getting the errors (other than the modifications needed for the path to your admin directory) from incorrect permissions on the script that should be set to 755 ?

John
Significant Media
Quote Reply
Re: [Jag] Suggest query (as in Google Suggest) In reply to
Hmmm. I'm still having the same problem after chmodding the file to 755.


mgeyman
Quote Reply
Re: [mgeyman] Suggest query (as in Google Suggest) In reply to
Hi,
Have you got access to your error_log to see if you have any more details than usual unhelpful internal error message ? In this case the debug option in the admin panel doesn't usually kick in for me so I have to go into my logs folder and figure out which line explains (if any Unsure) what is actually going on.
Sorry can't be of any more help I haven't installed Yogi's new work (thanks for your work BTW Yogi !) so I'm not sure whether it's a general bug or something on your server.

John
Significant Media
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Hi Yogi,

Thank you very much for the plugin. It works great. One small problem: after the suggestion box appears and click somewhere on the page, the box should disappear automatically as implemented by Google, but it won't disappear on my installation. If you could fix it, that would be great.

Another problem is it seems not work in Opera. In Netscape, the suggestion doesn't popup as a floating box, but appear within the page.

Thanks again.

Long

Last edited by:

long327: Dec 14, 2004, 12:59 AM
Quote Reply
Re: [long327] Suggest query (as in Google Suggest) In reply to
In Reply To:
Thank you very much for the plugin. It works great.[/quote]You're welcome.

As for your problems, I think you can find the solution on http://blog4.bitflux.ch/wiki/LiveSearch. On the same page you will find a list of supported browsers.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Thanks Yogi. I can confirm that it works.
(and also that it works in firefox)
John
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
Taking a look at it, it's officially cool! Smile

</not a clue>
Quote Reply
Re: [Dinky] Suggest query (as in Google Suggest) In reply to

As a part of the search results, I want to give also suggestions for word combinations and phrases (such as in Yahoo's: "try also:…").
The same way this script anticipates or completes the search word or phrase while the visitor is typing it, can you give the same list of suggestions in the search results?

Quote Reply
Re: [Jag] Suggest query (as in Google Suggest) In reply to
My host provider emailed me back with this information of why I keep getting an Ineternal Server Error when I type characters into the Search box:

Oh I see. That doesn't happen with Firefox. Here are the errors from the logs
[Fri Dec 17 17:50:11 2004] [error] [client 202.58.246.163] Premature end of script headers: livesearch.cgi, referer:
http://www.ohiobiz.com/livesearch.html
[Fri Dec 17 17:50:11 2004] [error] [client 202.58.246.163] Can't open perl script "!": No such file or directory, referer:
http://www.ohiobiz.com/livesearch.html
So basically, it's trying to open livesearch.html as a perl script. But it's not perl, it's html.

I would I fix this?

Thanks.

mgeyman

Quote Reply
Re: Suggest query (as in Google Suggest) In reply to
Hi,

before I start looking at installing this plugin (which I think is superb by the way) I've got a question.

in my browser if I have a search box it attempts to auto complete forms by an option I have selected in my browser.

How will this pluging manage that, does it over ride the settings for auto complete.

I am not too hot with code but I hope I will be able to manage this, can I make the suggested results drop down rather than appear at the side, my search bar is on the right .. or does it auto fit the suggestions anyway i.e they will appear on the left if there isn't room on the right.

Last question, it uses search logger. Is it possible to remove search terms that returned 0 results, this option is not available in search logger as it is used for a different purpose, all I can do is purge results but I don't want to purge or it loses functionality but also I don't want 0 searches returned.

Thanks in advance,

Kev

Cheers
KevM
Quote Reply
Re: [yogi] Suggest query (as in Google Suggest) In reply to
Does anyone have this working beside Yogi..

I followed the steps above but it will not work..

http://www.2muslims.com/...earch/new_page_3.htm
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Suggest query (as in Google Suggest) In reply to
I still can't get it to work properly either.

mgeyman
Quote Reply
Re: [mgeyman] Suggest query (as in Google Suggest) In reply to
It works Smile

For 3.xx, you need to change the call to the database table from SearchLog to SearchLogs.
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
For the life of me I can't get this to work!!!

Could I send you a copy of my files to have you take a quick look?

I keep getting an Internal Error 500 Message on my page when I start to type in a term (http://dir.ohiobiz.com/livesearch.html).

Thanks.

Mark
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
So

I have both:

livesearch.js
livesearch.css

Have the livesearch.cgi as described above...
Changed livesearch.js to reflect our URL in it..

Still nothing comes up..

Any ideas cus this is all what the instructions says..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
> >