function apachesolr_multilingual_apachesolr_field_name_map_alter in Apache Solr Multilingual 6.2
Same name and namespace in other branches
- 6.3 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_field_name_map_alter()
- 6 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_field_name_map_alter()
- 7 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_field_name_map_alter()
Implements hook_apachesolr_field_name_map_alter().
File
- ./
apachesolr_multilingual.module, line 267 - Multilingual search using Apache Solr.
Code
function apachesolr_multilingual_apachesolr_field_name_map_alter(&$map) {
$active_languages = locale_language_list();
$solr = apachesolr_get_solr();
$fields = $solr
->getFields();
foreach ($fields as $field_name => $field) {
// Only indexed fields are searchable.
if ($field->schema[0] == 'I') {
if ('text' != $field->type && strpos($field->type, 'text') === 0 && strpos($field->type, 'textSpell') !== 0) {
// serach for language identifier at last or second position within the field name
$tmp = explode('_', $field_name);
$lang = array_pop($tmp);
if (empty($active_languages[$lang])) {
$tmp[] = $lang;
if (!empty($active_languages[$tmp[1]])) {
$lang = $tmp[1];
unset($tmp[1]);
}
}
$base_field_name = implode('_', $tmp);
if (!empty($active_languages[$lang])) {
$map[$field_name] = '<em>' . $active_languages[$lang] . '</em> - ' . $map[$base_field_name];
}
}
}
}
}