Implements hook_update_index().
function node_update_index() {
$limit = (int) config('search.settings')
->get('index.cron_limit');
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array(
'target' => 'slave',
));
$nids = $result
->fetchCol();
if (!$nids) {
return;
}
// The indexing throttle should be aware of the number of language variants
// of a node.
$counter = 0;
foreach (node_load_multiple($nids) as $node) {
// Determine when the maximum number of indexable items is reached.
$counter += count($node
->getTranslationLanguages());
if ($counter > $limit) {
break;
}
_node_index_node($node);
}
}