Distributed Solr Indexing from Drupal
According to the documentation, the function hook_apachesolr_index_document_build(), on line 373 of file apachesolr.api.php, is not a reference value, instead directly a variable. So, the code should be:

function hook_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {

}


Also, from the code you use, I suspect the following possibilities:  


You are adding the code to the core node module, which is never recommended, as one should never hack core.
If you are adding this code to a custom module, and name that module node (as you mentioned in the comment of the code), that will conflict with the core node module, and might cause conflicts and break down your code.
If you add this code to a custom module (with a different name), then it is a wrong way to implement a hook in custom module. Follow this guide to get started with module development.
Lets say, if you name your module "custom_search", then you should place this code in the file custom_search.module, and implement it in the following way:

function custom_search_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {

}


Note that, I've replace the hook in the function name with the module name "custom_search"