Distributed Solr Indexing from Drupal I want a sharded Solr environment so that I can distribute data and query accordingly. Started two solr instances as described here.

Since Solr doesn't support (fully yet) writing automatically into different Solr instances, I have to do it manually.

I'm trying to do it in the following hook:

/* "node" is the module name. */
function node_apachesolr_index_document_build($document, $entity, $entity_type, &amp;$env_id)
{
}


Note that I'm trying to change the $env_id by making it a reference parameter, since that's what I want to change based on certain logic. When the cron is run, I get the error:


  Warning: Parameter 4 to node_apachesolr_index_document_build() expected to be a reference, value given in module_invoke_all() (line 857 of /var/www/drupal-7.17/includes/module.inc)


since it messes up with existing calls.

Any idea how to workaround this? Thanks.
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"