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.

Comments

dries’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs review » Reviewed & tested by the community

I've committed this to CVS HEAD. Needs to go into DRUPAL-6 as well. I leave that up to Gabor.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new976 bytes

I 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.

damien tournoud’s picture

Version: 6.x-dev » 7.x-dev
Status: Fixed » Needs work

That 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.

damien tournoud’s picture

Ok, 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.

gpk’s picture

Title: Fix negative percentage on search status page » Indexing status shown on search settings page is incorrect

Looks 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..!

jhodgdon’s picture

This looks like it should be pretty easy to fix, and it looks like it should be fixed for D7...

gpk’s picture

Minor note for the avoidance of confusion.. up to 5.x, unpublished nodes are never indexed - this behavior changed in Drupal 6.

jhodgdon’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB

Here'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.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks all.

gpk’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)
brianfisher’s picture

StatusFileSize
new854 bytes

ported to d6

gpk’s picture

Status: Needs work » Needs review

Resetting 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)

Status: Patch (to be ported) » Needs work

The last submitted patch, d6.patch, failed testing.

nancydru’s picture

Status: Needs review » Needs work

Well, 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.

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev
Issue summary: View changes
Status: Needs work » Fixed

Talked 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.