2 * Implements hook_update_index().
4 function {{ machine_name }}_update_index() {
5 $limit = (int)variable_get('search_cron_limit', 100);
7 $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);
9 foreach ($result as $node) {
10 $node = node_load($node->nid);
12 // Save the changed time of the most recent indexed node, for the search
13 // results half-life calculation.
14 variable_set('node_cron_last', $node->changed);
17 node_build_content($node, 'search_index');
18 $node->rendered = drupal_render($node->content);
20 $text = '<h1>' . check_plain($node->title) . '</h1>' . $node->rendered;
22 // Fetch extra data normally not visible
23 $extra = module_invoke_all('node_update_index', $node);
24 foreach ($extra as $t) {
29 search_index($node->nid, 'node', $text);