function apachesolr_batch_index_nodes in Apache Solr Search 6.2
Batch Operation Callback
1 string reference to 'apachesolr_batch_index_nodes'
- apachesolr_batch_index_remaining in ./
apachesolr.admin.inc - Submit a batch job to index the remaining, unindexed content.
File
- ./
apachesolr.admin.inc, line 846 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_batch_index_nodes(&$context) {
if (empty($context['sandbox'])) {
try {
// Get the $solr object
$solr = apachesolr_get_solr();
// If there is no server available, don't continue.
if (!$solr
->ping()) {
throw new Exception(t('No Solr instance available during indexing.'));
}
} catch (Exception $e) {
watchdog('Apache Solr', $e
->getMessage(), NULL, WATCHDOG_ERROR);
return FALSE;
}
$status = apachesolr_index_status('apachesolr_search');
$context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = $status['remaining'];
}
// We can safely process the apachesolr_cron_limit nodes at a time without a
// timeout or out of memory error.
$limit = variable_get('apachesolr_cron_limit', 50);
// With each pass through the callback, retrieve the next group of nids.
$rows = apachesolr_get_nodes_to_index('apachesolr_search', $limit);
apachesolr_index_nodes($rows, 'apachesolr_search');
$context['sandbox']['progress'] += count($rows);
$context['message'] = t('Indexed @current of @total nodes', array(
'@current' => $context['sandbox']['progress'],
'@total' => $context['sandbox']['max'],
));
// Inform the batch engine that we are not finished, and provide an
// estimation of the completion level we reached.
$context['finished'] = empty($context['sandbox']['max']) ? 1 : $context['sandbox']['progress'] / $context['sandbox']['max'];
// Put the total into the results section when we're finished so we can
// show it to the admin.
if ($context['finished']) {
$context['results']['count'] = $context['sandbox']['progress'];
}
}