Because synonyms works by adding synonyms to the general index, when using advanced search to specifically search for the category (which someone looking for content tagged with a synonym of a term is rather likely to do), it does not show content that it does find by normal search.

Have not looked into this feasibility but it would be good to have Drupal core advance search and/or Views Fast Search etc. understand that terms have synonyms.

Comments

funkytraffic’s picture

Well it would be nice to implement an overwrite of the taxonomy autocomlete function into this module. Here I just changed the sql query.

So if a synonym is search by the autocomplete the original term will be suggested.


/**
 * Helper function for autocompletion
 */
function taxonomy_autocomplete($vid, $string = '') {
  // The user enters a comma-separated list of tags. We only autocomplete the last tag.
  $array = drupal_explode_tags($string);

  // Fetch last tag
  $last_string = trim(array_pop($array));
  $matches = array();
  if ($last_string != '') {
    $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t 
       LEFT JOIN {term_synonym} ts  ON t.tid = ts.tid 
       WHERE t.vid = %d 
	   AND ((LOWER(t.name) LIKE LOWER('%%%s%%')) OR (LOWER(ts.name) LIKE LOWER('%%%s%%')))", 't', 'tid'), 
	   $vid, $last_string,  $last_string, 0, 10);

    $prefix = count($array) ? implode(', ', $array) .', ' : '';

    while ($tag = db_fetch_object($result)) {
      $n = $tag->name;
      // Commas and quotes in terms are special cases, so encode 'em.
      if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
        $n = '"'. str_replace('"', '""', $tag->name) .'"';
      }
      $matches[$prefix . $n] = check_plain($tag->name);
    }
  }

  drupal_json($matches);
}

bucefal91’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

I am going to close this issue since it's about D6.