function apachesolr_term_solr_taxonomy_ancestors in Apachesolr Term 7
1 call to apachesolr_term_solr_taxonomy_ancestors()
- apachesolr_term_solr_document in ./
apachesolr_term.module - Builds the user-specific information for a Solr document.
File
- ./
apachesolr_term.module, line 95 - Indexer for the userhook_apachesolr_entity_info_alter entities for the Apachesolr module.
Code
function apachesolr_term_solr_taxonomy_ancestors($term) {
static $ancestors = array();
$vocab_names = array();
if (!isset($ancestors[$term->tid])) {
$ancestors[$term->tid] = taxonomy_get_parents_all($term->tid);
}
foreach ($ancestors[$term->tid] as $ancestor) {
// Index parent term against the field. Note that this happens
// regardless of whether the facet is set to show as a hierarchy or not.
// We would need a separate field if we were to index terms without any
// hierarchy at all.
$fields[] = array(
'key' => 'tid',
'value' => $ancestor->tid,
);
$fields[] = array(
'key' => 'im_vid_' . $ancestor->vid,
'value' => $ancestor->tid,
);
$name = apachesolr_clean_text($ancestor->name);
$vocab_names[$ancestor->vid][] = $name;
// We index each name as a string for cross-site faceting
// using the vocab name rather than vid in field construction .
$fields[] = array(
'key' => 'sm_vid_' . apachesolr_vocab_name($ancestor->vid),
'value' => $name,
);
}
foreach ($vocab_names as $vid => $names) {
$fields[] = array(
'key' => 'tm_vid_' . $vid . '_names',
'value' => implode(' ', $names),
);
}
return $fields;
}