A client has requested certain keywords have synonyms when searching. Unfortunately, the search does not seem to have a way to specify synonyms to specific keywords.
Currently, if one uses a term as a keyword, all nodes in that term will come up in the result. Yet, it won't associate term synonyms with the nodes when searching.
For example, say we sell products, and have a category "Copy Machines" with a specific product "HP Photocopier." The issue we're having is that if someone searches "xerox" they will get no results because we offer no xerox brand copy machines.
Since we can anticipate such branding confusion, we would like to have some way of associating certain keywords with synonyms.
I attempted to associate category synonyms with nodes utilizing this script:
<?php
$nodeTerms = taxonomy_node_get_terms(arg(1));
foreach($nodeTerms as $nodeTerm) {
$parents = taxonomy_get_parents_all($nodeTerm->tid);
foreach($parents as $parent) {
print '<a href="'. drupal_get_path_alias('taxonomy/term/'. $parent->tid) .'" title="'. $parent->name .'">'. $parent->name .'</a> ';
$parentSynonyms = taxonomy_get_synonyms($parent->tid);
foreach($parentSynonyms as $parentSynonym) {
print '<a href="'. drupal_get_path_alias('taxonomy/term/'. $parent->tid) .'" title="'. $parentSynonym .'">'. $parentSynonym .'</a> ';
}
}
}
?>
It successfully will list all categories, parent categories and synonyms related to the node, but the Drupal search is unable to index the results of the script. When the script is placed in the node's template, I imagine Drupal's search can't see it at all... and when placed within the node's content fields, I imagine Drupal's search doesn't parse the result of the script before indexing.