Last updated October 7, 2010. Created by wmostrey on October 7, 2010.
Log in to edit this page.
By default the Apache Solr module has a setting to exclude content types from the search index. If you want more control and exclude certain individual nodes you can use hook_apachesolr_node_exclude().For the following example I first created a cck checkbox named "field_exclude_search" in the story content type to control whether the node should be indexed or not.
Example use of hook_apachesolr_node_exclude() for both 6.x-1.x and 6.x-2.x:
<?php
/**
* Implementation of hook_apachesolr_node_exclude()
*/
function mymodule_apachesolr_node_exclude($node) {
if ($node->type=="story" && $node->field_exclude_search[0]['value']) {
apachesolr_delete_node_from_index($node);
return TRUE;
}
}
?>Note that hook_apachesolr_node_exclude() only prevents the node from getting indexed, it does not remove an already indexed node from the index. That's why we also call apachesolr_delete_node_from_index().