Index: modules/node/node.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.api.php,v
retrieving revision 1.72
diff -u -r1.72 node.api.php
--- modules/node/node.api.php	22 Aug 2010 13:52:58 -0000	1.72
+++ modules/node/node.api.php	31 Aug 2010 18:41:42 -0000
@@ -115,6 +115,8 @@
  *   - Node is loaded (see Loading section above)
  *   - Node is prepared for viewing (see Viewing a single node above)
  *   - hook_node_update_index() (all)
+ *   - hook_update_index() (all non-search modules with hook_ranking or
+ *     hook_node_update_index() implementations)
  * @}
  */
 
@@ -613,6 +615,12 @@
  * This hook is invoked during search indexing, after node_load(), and after
  * the result of node_view() is added as $node->rendered to the node object.
  *
+ * In addition, any module implementing this hook can also implement
+ * hook_update_index(). When node_update_index() is invoked, it will also
+ * invoke your module's hook_update_index() at the end so that your module can
+ * perform any calculations needed to maintain its search indexing that are
+ * unrelated to a particular node.
+ *
  * @param $node
  *   The node being indexed.
  *
@@ -826,6 +834,12 @@
  * and then the weighted scores from all ranking mechanisms are added, which
  * brings about the same result as a weighted average.
  *
+ * In addition, any module implementing hook_ranking() can also implement
+ * hook_update_index(). When node_update_index() is invoked, it will also
+ * invoke your module's hook_update_index() at the end so that your module can
+ * perform any calculations needed in order to calculate its ranking (such as
+ * normalization).
+ *
  * @return
  *   An associative array of ranking data. The keys should be strings,
  *   corresponding to the internal name of the ranking mechanism, such as
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1294
diff -u -r1.1294 node.module
--- modules/node/node.module	30 Aug 2010 05:58:46 -0000	1.1294
+++ modules/node/node.module	31 Aug 2010 18:41:42 -0000
@@ -2534,6 +2534,16 @@
   foreach ($result as $node) {
     _node_index_node($node);
   }
+
+  // Invoke hook_update_index() on any modules that implement hook_ranking() or
+  // hook_node_update_index(), as they may have things that need to be done
+  // after the node indexes are finished. Since they are not active search
+  // modules, their hook_update_index() implementations are not invoked
+  // otherwise. But make sure to exclude any active search modules.
+  $modules = array_diff(array_unique(array_merge(module_implements('ranking'), module_implements('node_update_index'))), variable_get('search_active_modules', array('node', 'user')));
+  foreach ($modules as $module) {
+    module_invoke($module, 'update_index');
+  }
 }
 
 /**
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.893
diff -u -r1.893 comment.module
--- modules/comment/comment.module	30 Aug 2010 05:58:46 -0000	1.893
+++ modules/comment/comment.module	31 Aug 2010 18:41:41 -0000
@@ -2564,7 +2564,7 @@
         'on' => 'node_comment_statistics.nid = i.sid',
       ),
       // Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
-      'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))',
+      'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * :scale)',
       'arguments' => array(':scale' => variable_get('node_cron_comments_scale', 0)),
     ),
   );
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.338
diff -u -r1.338 statistics.module
--- modules/statistics/statistics.module	30 Aug 2010 05:58:46 -0000	1.338
+++ modules/statistics/statistics.module	31 Aug 2010 18:41:42 -0000
@@ -409,7 +409,7 @@
           'on' => 'node_counter.nid = i.sid',
         ),
         // Inverse law that maps the highest view count on the site to 1 and 0 to 0.
-        'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))',
+        'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * :scale)',
         'arguments' => array(':scale' => variable_get('node_cron_views_scale', 0)),
       ),
     );
