How to find bad a node that makes search indexing to fail in Drupal 7

To find out which node is causing the indexing problem you have to modify the following in “modules/node/node.module”


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

  // Store the maximum possible comments per thread (used for ranking by reply count)
  variable_set('node_cron_comments_scale', 1.0 / max (link is external)(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
  variable_set('node_cron_views_scale', 1.0 / max (link is external)(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));

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

  while ($node = db_fetch_object($result)) {
    watchdog ('cron', "indexing node {$node -> nid}"); // ADD THIS LINE

After that go to “/admin/config/system/cron” to find the cron jobs, there you will find a job called “search_cron” , click on run then go to the logs to find which node is causing the problem

Common reason for the problem
Normally this problem happens because of some bad php in a node or because of a drupal_goto call in some php.

People often recommend disabling the module “PHP Filter”, clearing the cache, running cron, then enabling it again.and other solutions also recommend you try to reduce the number of items you index when cron runs.

Leave a Comment.