When updating the search index for a specific node, this module first adds the term itself to the search index before moving on to adding the synonyms. This is completely unnecessary since that is already done by taxonomy.module. This might even be considered harmful as it actually improves the score of the term in the search index. The solution is to simply remove this line:

<?php $text .= ' '. $nodeTerm->name .' '; ?>

Another issue is that the synonyms aren't added in a way that is consistent with how taxonomy.module adds the main terms, which gives them a lower score than the terms (see taxonomy_node_update_index()).

I'd suggest we rewrite the function to collect the synonyms in an array, the same way taxonomy_node_update_index() does:

<?php

function synonyms_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'update index') {
    $text = array();

    $getTerms = taxonomy_node_get_terms($node->nid);
    foreach($getTerms as $nodeTerm) {
        $childSynonyms = taxonomy_get_synonyms($nodeTerm->tid);
        foreach($childSynonyms as $childSynonym){
            $text[] = $childSynonym;
        }
        $parents = taxonomy_get_parents($nodeTerm->tid);
        foreach($parents as $parent) {
            $text[] = $parent->name;
            $synonyms = taxonomy_get_synonyms($parent->tid);
            foreach($synonyms as $synonym){
                $text[] = $synonym;
            }
        }
    }

  return '<strong>('. implode(', ', $text) .')</strong>';
  }
}

?>

Comments

doc2@drupalfr.org’s picture

Thank you for your help. I need such a module, but I cannot explode my database by indexing twice, eventhough it's limited to taxonomy terms.

Can I just copy-paste this piece of code into the synonyms.module? Whereabout?

Or could there be a patch? Thank you in advance.

doc2@drupalfr.org’s picture

I don't know how to rewrite this code for the module.

Could someone try to release a fixed version of the module, implementing on those issues?

zoo33’s picture

This is a super easy change to a microscopic module, but sadly this module doesn't seem to be maintained at all. I'll try to contact the maintainer and ask him to commit this change. I'll also volunteer to take over the module if he's lost interest in it.

doc2@drupalfr.org’s picture

I'll also volunteer to take over the module if he's lost interest in it.

Woooh, dat's great!

Hope it'll be commited soon. Good luck!

bojanz’s picture

Hi guys!
I'm really sorry for ignoring this, the module was contributed as an afterthought after a small project of mine, didn't really think anyone was interested!

Thank you zoo33 for reminding me this exists ;)

I will update the module in the next 24h and go through the other requests.

zoo33’s picture

That's great, thanks!

bojanz’s picture

Status: Active » Fixed

Checkout the new release (1.1)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.