You are here

static function ApacheSolrUpdate::getNodesToIndex in Apache Solr Search 5

Function to generically handle the fetching of nodes that need indexing on a cron run. It takes a namespace which needs to be unique to the calling module and manages all of the global variables and the shutdown function so that every search implementation can have its own without needing to duplicate the query. Returns a db_query $result. Modules need to then call apache_update_success after each node is successfully indexed.

1 call to ApacheSolrUpdate::getNodesToIndex()
ApacheSolrUpdate::update_index in ./apachesolr.module

File

./apachesolr.module, line 283
Integration with the Apache Solr search application.

Class

ApacheSolrUpdate
The point of this class is to manage the update index needs of multiple search modules. Each one needs to track its own list of nodes that need updating.

Code

static function getNodesToIndex($namespace) {
  register_shutdown_function('apachesolr_shutdown');
  $cron_change = self::get_change($namespace);
  $cron_last = self::get_last($namespace);
  $cron_limit = variable_get('search_cron_limit', 100);
  $result = db_query_range('SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid ' . 'FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid ' . 'WHERE n.status = 1 ' . 'AND ((GREATEST(IF(c.last_comment_timestamp IS NULL , 0, c.last_comment_timestamp ), n.changed) = %d AND n.nid > %d) OR n.changed > %d OR c.last_comment_timestamp > %d) ' . 'ORDER BY last_change ASC, n.nid ASC', $cron_change, $cron_last, $cron_change, $cron_change, 0, $cron_limit);
  return $result;
}