Create a Drupal site with 5 nodes. Unpublish one. Enable the search module. Got to admin/settings/search and you will be shown a phrase like:
-20% of the site has been indexed. There are 5 items left to index.
This is because the query we use to count the total does not count unpublished nodes:
SELECT COUNT(*) FROM {node} WHERE status = 1
whereas the query we use to count remaining has no provision for ignoring unpublished nodes:
SELECT COUNT(*) 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
This patch adds the status = 1 to the WHERE clause of the second query. If that's the wrong approach for some reason (I don't have my head in search module) we should at least compare remaining to total and if it's greater, set it equal to total.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | d6.patch | 854 bytes | brianfisher |
| #8 | 239196.patch | 1.07 KB | jhodgdon |
| #2 | negpercent-2.patch | 976 bytes | gábor hojtsy |
| negpercent.patch | 974 bytes | jvandyk |
Comments
Comment #1
dries commentedI've committed this to CVS HEAD. Needs to go into DRUPAL-6 as well. I leave that up to Gabor.
Comment #2
gábor hojtsyI added parenthesis to note the relation of the different parts of the expression and to ensure it is evident. Committed this one to Drupal 6.
Comment #3
damien tournoud commentedThat issue was discussed here: http://drupal.org/node/207734
The fix here seems wrong. According to remarks #12 and #14 from the above issue, all nodes gets indexed regardless of their status.
To be consistent, we will have to either (1) change the node count or (2) change the indexing logic so as to not index unpublished nodes.
Comment #4
damien tournoud commentedOk, this still an issue: all nodes get indexed by
node_update_index()(regardless of their status), while the percentage status only takes into account published nodes.Comment #5
gpk commentedLooks like this still affects 7.x and 6.x, and the original negative percentage problem was never fixed in 5.x.
The problem now is that while unpublished nodes are indexed (http://api.drupal.org/api/function/node_update_index/7), they are not included in the report of indexing status (http://api.drupal.org/api/function/node_search_status/7, which could also do with the parentheses per #2 ... ).
All a bit confusing if you are trying to pin down an indexing problem and actually believe the figures shown..!
Comment #6
jhodgdonThis looks like it should be pretty easy to fix, and it looks like it should be fixed for D7...
Comment #7
gpk commentedMinor note for the avoidance of confusion.. up to 5.x, unpublished nodes are never indexed - this behavior changed in Drupal 6.
Comment #8
jhodgdonHere's a patch that fixes the status reporting.
As noted above, search indexes all nodes, published and unpublished, so the status page needs to report on the same nodes.
Comment #9
dries commentedCommitted to CVS HEAD. Thanks all.
Comment #10
gpk commentedComment #11
brianfisher commentedported to d6
Comment #12
gpk commentedResetting status as we have a patch (for a while now). Though #11 is an old (pre-GIT) patch and therefore I presume in the wrong format (hoping the bot will confirm this)
Comment #14
nancydruWell, after I applied this (6.x), the number remaining jumped from 472 to 11,260.
I really question the "remaining" query. There are duplicate "sid" values in the search_dataset and they really don't look so much like nids, although they may be. Would using the search_node_links table be better.
Comment #15
jhodgdonTalked with Gabor (the Drupal 6 branch maintainer) and D6 issues are really not being committed unless they're really essential -- we really don't have a test system for Drupal 6 and it's too dangerous. So... putting this back to D7 / fixed.