function hook_update_index


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 search.api.php hook_update_index()
cle7 search.api.php hook_update_index()
elmsmedia7 search.api.php hook_update_index()
icor7 search.api.php hook_update_index()
meedjum_blog7 search.api.php hook_update_index()
mooc7 search.api.php hook_update_index()

Update the search index for this module.

This hook is called every cron run if search.module is enabled, your module has implemented hook_search_info(), and your module has been set as an active search module on the Search settings page (admin/config/search/settings). It allows your module to add items to the built-in search index using search_index(), or to add them to your module's own indexing mechanism.

When implementing this hook, your module should index content items that were modified or added since the last run. PHP has a time limit for cron, though, so it is advisable to limit how many items you index per run using variable_get('search_cron_limit') (see example below). Also, since the cron run could time out and abort in the middle of your run, you should update your module's internal bookkeeping on when items have last been indexed as you go rather than waiting to the end of indexing.

Related topics

8 functions implement hook_update_index()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

advanced_help_update_index in sites/all/modules/ulmus/advanced_help/advanced_help.module
Implements hook_update_index().
comment_node_update_index in modules/comment/comment.module
Implements hook_node_update_index().
comment_update_index in modules/comment/comment.module
Implements hook_update_index().
ds_search_update_index in sites/all/modules/ulmus/ds/modules/ds_search/ds_search.module
Implements hook_node_update_index().
file_entity_update_index in sites/all/modules/ulmus/file_entity/file_entity.module
Implements hook_update_index().

... See full list

1 invocation of hook_update_index()
search_cron in modules/search/search.module
Implements hook_cron().


modules/search/search.api.php, line 308
Hooks provided by the Search module.


function hook_update_index() {
  $limit = (int) variable_get('search_cron_limit', 100);

  $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);

  foreach ($result as $node) {
    $node = node_load($node->nid);

    // Save the changed time of the most recent indexed node, for the search
    // results half-life calculation.
    variable_set('node_cron_last', $node->changed);

    // Render the node.
    node_build_content($node, 'search_index');
    $node->rendered = drupal_render($node->content);

    $text = '<h1>' . check_plain($node->title) . '</h1>' . $node->rendered;

    // Fetch extra data normally not visible
    $extra = module_invoke_all('node_update_index', $node);
    foreach ($extra as $t) {
      $text .= $t;

    // Update index
    search_index($node->nid, 'node', $text);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.