diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 0fce7ec..67bf9a4 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1037,10 +1037,11 @@ function comment_node_update_index(EntityInterface $node, $langcode) {
 }
 
 /**
- * Implements hook_update_index().
+ * Implements hook_cron().
  */
-function comment_update_index() {
-  // Store the maximum possible comments per thread (used for ranking by reply count)
+function comment_cron() {
+  // Store the maximum possible comments per thread (used for node search
+  // ranking by reply count).
   \Drupal::state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {comment_entity_statistics}')->fetchField()));
 }
 
@@ -1623,8 +1624,8 @@ function comment_ranking() {
         'on' => "ces.entity_id = i.sid AND ces.entity_type = 'node' AND ces.field_id = 'node__comment'",
       ),
       // Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
-      'score' => '2.0 - 2.0 / (1.0 + ces.comment_count * CAST(:scale AS DECIMAL))',
-      'arguments' => array(':scale' => \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0),
+      'score' => '2.0 - 2.0 / (1.0 + ces.comment_count * :scale)',
+      'arguments' => array(':scale' => (float) \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0),
     ),
   );
 }
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
index cc9da27..860d7e2 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
@@ -80,10 +80,6 @@ public function testRankings() {
       }
     }
 
-    // Update the search index.
-    $this->nodeSearch->getPlugin()->updateIndex();
-    search_update_totals();
-
     // Add a comment to one of the nodes.
     $edit = array();
     $edit['subject'] = 'my comment title';
@@ -95,22 +91,16 @@ public function testRankings() {
     // Enable counting of statistics.
     \Drupal::config('statistics.settings')->set('count_content_views', 1)->save();
 
-    // Then View one of the nodes a bunch of times.
-    // Manually calling statistics.php, simulating ajax behavior.
-    $client = \Drupal::httpClient();
-    $client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10)));
+    // Simulating content views is kind of difficult in the test. Leave that
+    // to the Statistics module. So instead go ahead and manually update the
+    // counter for this node.
     $nid = $nodes['views'][1]->id();
-    global $base_url;
-    $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
-    for ($i = 0; $i < 5; $i ++) {
-      $client->post($stats_path, array(), array('nid' => $nid))->send();
-    }
+    db_insert('node_counter')
+      ->fields(array('totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid))
+      ->execute();
 
-    // @todo - comments and views are removed from the array since they are
-    // broken in core. Those modules expected hook_update_index() to be called
-    // even though it was only called on modules that implemented a search type.
-    array_pop($node_ranks);
-    array_pop($node_ranks);
+    // Run cron to update the search index and comment/statistics totals.
+    $this->cronRun();
 
     // Test that the settings form displays the context ranking section.
     $this->drupalGet('admin/config/search/settings/manage/node_search');
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index a5fad17..4f7a6a7 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -105,6 +105,9 @@ function statistics_cron() {
       ->execute();
     \Drupal::state()->set('statistics.day_timestamp', REQUEST_TIME);
   }
+
+  // Calculate the maximum of node views, for node search ranking.
+  \Drupal::state()->set('statistics.node_counter_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
 }
 
 /**
@@ -228,21 +231,14 @@ function statistics_ranking() {
           '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))',
-        'arguments' => array(':scale' => \Drupal::state()->get('statistics.node_counter_scale') ?: 0),
+        'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * :scale)',
+        'arguments' => array(':scale' => (float) \Drupal::state()->get('statistics.node_counter_scale') ?: 0),
       ),
     );
   }
 }
 
 /**
- * Implements hook_update_index().
- */
-function statistics_update_index() {
-  \Drupal::state()->set('statistics.node_counter_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
-}
-
-/**
  * Implements hook_preprocess_HOOK() for block templates.
  */
 function statistics_preprocess_block(&$variables) {
