function apachesolr_term_solr_document in Apachesolr Term 7
Builds the user-specific information for a Solr document.
Parameters
ApacheSolrDocument $document: The Solr document we are building up.
stdClass $entity: The entity we are indexing.
string $entity_type: The type of entity we're dealing with.
1 string reference to 'apachesolr_term_solr_document'
- apachesolr_term_apachesolr_entity_info_alter in ./
apachesolr_term.module - @file Indexer for the userhook_apachesolr_entity_info_alter entities for the Apachesolr module.
File
- ./
apachesolr_term.module, line 27 - Indexer for the userhook_apachesolr_entity_info_alter entities for the Apachesolr module.
Code
function apachesolr_term_solr_document(ApacheSolrDocument $document, $term, $entity_type) {
$document->tid = $term->tid;
// Title is a required field.
$document->label = apachesolr_clean_text(format_username($term));
$term_tree = apachesolr_term_solr_taxonomy_ancestors($term);
foreach ($term_tree as $tt => $td) {
$document
->addField($td['key'], apachesolr_clean_text($td['value']));
}
// Note the conspicuous lack of password hash. :-)
$build = taxonomy_term_view($term, 'search_index');
// Why do we need this?
unset($build['#theme']);
$text = drupal_render($build);
$document->content = apachesolr_clean_text($text);
// Generic usecase for future reference. Callbacks can
// allow you to send back multiple documents
$documents = array();
$documents[] = $document;
return $documents;
}