Gossamer Forum
Home : Products : Links 2.0 : Customization :

How do you make category KEYWORDS searchable?

Quote Reply
How do you make category KEYWORDS searchable?
 
OK, I give up... what's the point of having category keywords --- which are stored in the category.db -- if the search tool only searches fields in links.db??

I need to have my search also search the keywords assigned to a category -- any idea how to do this?

For example, in my case I have CATGORIES of peoples names -- in last name first name format, for example "Smith_Bob"

...but when someone searches on "Bob Smith" I want the category to come up, so I added I keyword of "Bob Smith" to the category. ...but the search fails to cover the category keyword.

Any solutions?

Thanks...
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
Just a point of clarification..the point of the Meta Keywords and Meta Description in categories is to automatically insert meta tags into your LINKS pages, so that it will be easier to get indexed by other search engines and portals.

I don't know how to make the Keywords field in categories searchable.

Sorry.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
First, add
Code:
require "$db_lib_path/category.def";
where all the others are in search.cgi., then see if one of my other posts can help you out. http://www.gossamer-threads.com/...um3/HTML/003013.html .

The post at the url was made to do basically what you want, but i opens the category.db also, and if you put the code up above, it should work, unless the 2 def files conflict.

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




Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
umm.. bmxer.. (bmx is a bike right?)

anyways..

requiring the category.def will mess up the db_def hash of the links.def

won't it?

jerry
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
Yeah, Bmxing is kinda big in Cali, like skating. I haven't really gotten this to work but i have one more thing to see. I wasn't sure about the db_def hashes, thats why in my post above i said it may mess up or something.

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




Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
yea.. i live in KaLi! Smile

anyways.. it does mess everything up.. you don't even need to require it and it will work... just make sure you use the right field numbers..

jerry
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
OK... now I'm confused.

...is someone saying that there is a way to have this work or are you saying no it won't work?

Thanks...
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
It should work but don't require the category.def file. I really don't see how it will read the right things if its using links.def unless lets say the links.def number 5 is description but in category.db its meta_keywords, then keywords will be description. But it will work alright for ID.
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
the field names are only used with hashes..

the only problem here is:

Code:
# Go through the database.
open (DB, "<$db_category_name") or &cgierr("error in search. unable to open database: $db_category_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;
# Check to see if the category matches.
$match = 0; $andmatch = 1;
if ($regexp) {
FIELD: foreach $field (@searchcat_fields) {
$_ = $values[$field];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
last FIELD if ($match);
}
}
# Check to see if the category matches any database fields. Only exact matches
# here.
if ($or_match | | $match | | !$regexp) {
FIELD: foreach $field (@field_search) {
if ($or_match) {
$match = $match | | ($in{$db_cols[$field]} eq $values[$field]);
$match and last FIELD;
}
else {
$match = ($in{$db_cols[$field]} eq $values[$field]);
$match or last FIELD;
}
}
}
$andmatch = $andmatch && $match;
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$category_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}

and then there are alot more.. you can't put it inside the other openin DB thing either..

to do it.. it's pretty easy.. the code you show here is on the right track.. but will lead to a dozen or more errors..

if i were you i would put something like this above where it opens the links.db..

Code:
@searchcat_fields = ();

# Go through the database.
open (DB, "<$db_category_name") or &cgierr("error in search. unable to open database: $db_category_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;
# Check to see if the category matches.
$match = 0; $andmatch = 1;
if ($regexp) {
FIELD: foreach $field (@searchcat_fields) {
$_ = $values[$field];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
last FIELD if ($match);
}
}
# Check to see if the category matches any database fields. Only exact matches
# here.
if ($or_match | | $match | | !$regexp) {
FIELD: foreach $field (@field_search) {
if ($or_match) {
$match = $match | | ($in{$db_cols[$field]} eq $values[$field]);
$match and last FIELD;
}
else {
$match = ($in{$db_cols[$field]} eq $values[$field]);
$match or last FIELD;
}
}
}
$andmatch = $andmatch && $match;
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@category_results, $values[1]);
$numhits++; # We have a match!
}
}
close DB;

i'm not saying that will work.. but it's more of what it should look like..

jerry
Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
oh yea.. and btw.. the split decode won't work right cause that sub uses the number of fields in the database.. and if you required category.def.. it will be that amount and screw up the links..

if you didn't require category.def.. you will get too many fields..

of course.. there are other problems with requiring category.def like db_cols and db_def and db_file_name

jerry