Dave,
I would like my main search to search one more SMALL field called "keywords" and not just "Product Name".
I will not search "description" (because its large) but wish to search "keywords" which are at most three words or so.
I found a few similar threads but they seem to go beyond my scope and there is a lot of going back and forth.
With my assumption that speed will not be a problem due to the small amount of keywords how would I go about implementing this?
Kind Regards
Hi,
The easiest way to go about this would actually be to use the code that is already in place to also search the description, but change each instance of "description" to "keywords" instead.
You'll find the code relevant to the full text index search method on line 148 of search.php:
$matchFields = "name,description";
...REPLACE that with:
$matchFields = "name,keywords";
...and for the basic search method (used if any word in the query is less than 4 characters long, or is a stopword) look for the following code on line 175:
$where .= " OR description LIKE '%".database_safe($word)."%'";
...and REPLACE with:
$where .= " OR keywords LIKE '%".database_safe($word)."%'";
...also look the following code on line 184:
$where .= " OR description LIKE '%".database_safe(substr($word,0,-1))."%'";
...and REPLACE with:
$where .= " OR keywords LIKE '%".database_safe(substr($word,0,-1))."%'";
Next, look for the following code on line 51 of setup.php
$sql = "CREATE FULLTEXT INDEX name_description ON `".$config_databaseTablePrefix."products` (name,description)";
...and REPLACE with:
$sql = "CREATE FULLTEXT INDEX name_keywords ON `".$config_databaseTablePrefix."products` (name,keywords)";
Finally, to activate the search in keywords, first set $config_searchDescription = TRUE; on line 10 of config.advanced.php, then then browse to setup.php where you will see the link to create the full text index...
Hope this helps!
Cheers,
David.