Chris@0: /** Chris@0: * Implements hook_update_index(). Chris@0: */ Chris@0: function {{ machine_name }}_update_index() { Chris@0: $limit = (int)variable_get('search_cron_limit', 100); Chris@0: Chris@0: $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); Chris@0: Chris@0: foreach ($result as $node) { Chris@0: $node = node_load($node->nid); Chris@0: Chris@0: // Save the changed time of the most recent indexed node, for the search Chris@0: // results half-life calculation. Chris@0: variable_set('node_cron_last', $node->changed); Chris@0: Chris@0: // Render the node. Chris@0: node_build_content($node, 'search_index'); Chris@0: $node->rendered = drupal_render($node->content); Chris@0: Chris@0: $text = '

' . check_plain($node->title) . '

' . $node->rendered; Chris@0: Chris@0: // Fetch extra data normally not visible Chris@0: $extra = module_invoke_all('node_update_index', $node); Chris@0: foreach ($extra as $t) { Chris@0: $text .= $t; Chris@0: } Chris@0: Chris@0: // Update index Chris@0: search_index($node->nid, 'node', $text); Chris@0: } Chris@0: }