Jump to:
| Project: | Drupal core |
| Version: | 4.6.1 |
| Component: | search.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
I discovered a problem with the search module on Drupal 4.6.1. I had the number of nodes to index on each cron run set to the default of 100, but after just one run it said the indexing was 99% complete. I have about 600 nodes on my site, so I knew that couldn't be right. After debugging for awhile, I think I figured out the problem:
In the node.module, in the function node_update_index(), on line 1716 the query finds nodes that has been created, changed, or last commented on since the last cron run:
$result = db_query_range('SELECT n.nid, c.last_comment_timestamp FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND n.moderate = 0 AND (n.created > %d OR n.changed > %d OR c.last_comment_timestamp > %d) ORDER BY GREATEST(n.created, n.changed, c.last_comment_timestamp) ASC', $last, $last, $last, 0, $limit);However, what about nodes that don't meet this criteria, but weren't indexed on the first cron run because it didn't get that far? Only the first 100 nodes would be indexed. The node_search() function has similar code to find the remaining number of nodes to index.
My workaround: I changed the number of nodes to index to 500, ran cron.php, and then changed my node_cron_last variable really far back and ran cron.php again. My thought is that now that all the nodes have been indexed once, any new nodes should be updated correctly.
Comments
#1
Not reproducible.
#2
There is no bug in that part at least: the node_cron_last variable is not set to the time of the last cron run, but the timestamp of the last indexed node. That's the whole point: so it can resume where it stopped the last time.
Please re-open if you can provide more info about your problem.
#3
I've got a similar problem. I did an upgrade to 4.6 before finding out that I needed a version of PCRE installed that supported UTF-8.
Now I've installed it, and search works-- but the search_index table is empty, and cron doesn't recreate the index since none of the nodes have been edited since the last cron run. So searches don't return an error anymore, but neither do they return any results.
Perhaps there should be some kind of sanity check, such that if the search_index table is empty, and the node table is not, that all nodes should be re-indexed, rather than only those that were edited since the last cron run.
#4
Another pre-incarnation of #139537: search indexing gets stuck: node_update_index() - if comment.module is disabled.