3

While using Search API it does not index the translated/localized terms.

So does it mean translated terms are not searchable with Search API?

any clue? thanks

2

I think that this is core issue that the search index does not add the localized term to the index, I solved that by implementing hook_node_update_index($node) and fetching the localized term name by querying it from database because I don't know why i18n_taxonomy_localize_terms function doesn't load the term properly. my code is below:

function mymodule_node_update_index($node) {
  $text = '';
  $tid = key($node->your_taxonomy['und'][0]['tid']);
  if($tid != 0) {
    $query = db_select('locales_target', 'lt');
    $query->addExpression('CONVERT(translation USING UTF8)', 'translation');
    $query->join('locales_source', 'ls', 'ls.lid = lt.lid');
    $query->condition('context', 'term:'.$tid.':name');
   $text = $query->execute()->fetchColumn();
  }

  return $text;
}

Note: in my case the text is Arabic so I converted the field character set from blob to utf8.

  • Great work @Omar , i ended up with having two different taxonomy terms instead of localizing. My localized taxonomy term was also in Arabic.Any how hopefully some one will make use of your code. – brainHax Jul 6 '14 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.