Gossamer Forum
Quote Reply
top keyword global
hello

is there a way to create a global to display a list of the top X keywords used, using Alex's keyword log?


Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] top keyword global In reply to
Try something like:

Code:
sub {

my $db = $DB->table('SearchLog');
my $x = 10;
my $output;

$db->select_options("ORDER BY HitCount DESC", "LIMIT $x");
my $sth = $db->select('Term','HitCount');

while (my $res = $sth->fetchrow_hashref) {
$output .= $res->{Term} . ' ' . $res->{HitCount} . '<br>';
}

return $output;

}
Quote Reply
Re: [PaulW] top keyword global In reply to
Thanks

What should I change to make the word linked to its search results page?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] top keyword global In reply to
Just change:

$output .= $res->{Term} . ' ' . $res->{HitCount} . '<br>';

to:

$output .= qq|$CFG->{db_cgi_url}/search.cgi?query=$res->{Term}">$res->{Term} - $res->{HitCount}<br>|;

I think that will work but you can change the query string if you need to.

Did it work ok apart from the URL problem?

Last edited by:

PaulW: Dec 6, 2001, 3:32 AM
Quote Reply
Re: [PaulW] top keyword global In reply to
Hi

The coplete global is :

sub {

my $db = $DB->table('SearchLog');
my $x = 10;
my $output;

$db->select_options("ORDER BY HitCount DESC", "LIMIT $x");
my $sth = $db->select('Term','HitCount');

while (my $res = $sth->fetchrow_hashref) {
$output .= qq|• <a href="$CFG->{db_cgi_url}/search.cgi?query=$res->{Term}">$res->{Term}</a> - $res->{HitCount}<br>|;}

return $output;

}

It works great

Thanks so much for the help..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] top keyword global In reply to
Great. Glad it worked!
Quote Reply
Re: [PaulW] top keyword global In reply to
Would it be much of a challenge to add some sort of smut word filter to the code?
Quote Reply
Re: [katabd] top keyword global In reply to
This works great!

Thanks PaulW and katabd Smile

Would there be a way to create some kind of SSI thing so that static HTML pages could still have the most up-to-date list of the Favorite Search Terms?

Maybe a separate .txt file could be created and pulled in?

Thanks very much.

------------------------------------------

Last edited by:

DogTags: Dec 9, 2001, 5:07 AM
Quote Reply
Re: [DogTags] top keyword global In reply to
Would there also be a way to display ONLY terms that have been found?

For example, I don't want to display a list like this:

0*&hk' - 8
*&ugg* - 7
*hhh6G - 6

I would only want to display things like:

dog tags - 5
military surplus - 5
camping - 3
fishing - 2

Thanks very much

------------------------------------------
Quote Reply
Re: [DogTags] top keyword global In reply to
I _think_ you'd need to change:

my $sth = $db->select('Term','HitCount');

...to something like:

my $cond = GT::SQL::Condition->new ('Results', '>', '0');
my $sth = $db->select($cond, ['Term','HitCount']);

I've not tested it :)
Quote Reply
Re: [PaulW] top keyword global In reply to
Bulls-Eye!

Thanks, Paul !

------------------------------------------
Quote Reply
Re: [PaulW] top keyword global In reply to
I'm in the process of rewriting my keywords program to be 2.1.x compliant.

It will add the ability to see the top keywords searched for per unit time as well. In it's raw form, it shows the overall top keywords, the top keywords for the day, and the top keywords for the month.

In case anyone was wondering how to do this, you need to create a separate table, which keeps track of the keyword + date as primary key. When the date changes, it creates a new primary key entry.

For performance reasons, entering the total searches for a keyword in the standard log table makes sense. You *could* use the above new table, but you'd have to do a complex search and count on each access... it's lower overhead on a "read mostly" system to maintain two tables. (If I'm wrong about that, I'd like to see the stats :)




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] top keyword global In reply to
That would be neat!

Thanks, pugdog!

------------------------------------------
Quote Reply
Re: [pugdog] top keyword global In reply to
PugDog, may I suggest some sort of bad word filter in your program? I'm thinking about such words being total ignored in the results rather that blocked by **** format. This would help make the plugin more usable across a wider variety of sites. What do you think?

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] top keyword global In reply to
Not too complicated...just run a check of the BAD WORD table versus the $query var, and if the query matches words in the BAD WORD table, then don't log the query...
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Eraser] top keyword global In reply to
Right now, it uses one of two systems -- the bad word tag in the config, as well as a set of hard-coded terms.

I'm not sure how to make this "universal" but I think the best way is to have an input box, with a text field, and let you enter all the words you want screened out. It will prompt you by importing the the bad-words list (if there is one) and then you can add to it. The reason is that you might want to allow people to _search_ for things you don't want to prompt them for :)

For instance, we allow people to search for "sex" but we don't list that as one of the top keywords :)




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] top keyword global In reply to
>>
I'm not sure how to make this "universal" but I think the best way is to have an input box, with a text field, and let you enter all the words you want screened out.
<<

Its pretty simple as a plugin. Just add a user option like "Bad Words" and loop through the Bad Words using regex to strip them out.

I made a similar plugin today which I'll be releasing tommorrow or the day after (for search results).



Last edited by:

PaulW: Dec 16, 2001, 7:44 PM
Quote Reply
Re: [PaulW] top keyword global In reply to
By universal, I meant to work in all the situations people are going to ask it work in. Using "bad_words" and then having an input box for excluded search terms is about the best compromise I could come up with.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.