function hook_apachesolr_index_document_build_ENTITY_TYPE in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr.api.php \hook_apachesolr_index_document_build_ENTITY_TYPE()
- 7 apachesolr.api.php \hook_apachesolr_index_document_build_ENTITY_TYPE()
Build the documents before sending them to Solr.
Supports all types of hook_apachesolr_index_document_build_' . $entity_type($documents[$id], $entity, $env_id);
The function is the follow-up for apachesolr_update_index but then for specific entity types
Parameters
ApacheSolrDocument $document:
object $entity:
string $env_id: The machine name of the environment.
File
- ./
apachesolr.api.php, line 405 - Exposed Hooks in 7.x:
Code
function hook_apachesolr_index_document_build_ENTITY_TYPE(ApacheSolrDocument $document, $entity, $env_id) {
// Index field_main_image as a separate field
if ($entity->type == 'profile') {
$user = user_load(array(
'uid' => $entity->uid,
));
// Hard coded field, not recommended for inexperienced users.
$document
->setMultiValue('sm_field_main_image', $user->picture);
}
}