diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 103f71d..f83f762 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -446,7 +446,9 @@ function comment_node_update_index(EntityInterface $node, $langcode) {
 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, \Drupal::service('comment.statistics')->getMaximumCount('node')));
+  if (\Drupal::moduleHandler()->moduleExists('search')) {
+    \Drupal::state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, \Drupal::service('comment.statistics')->getMaximumCount('node')));
+  }
 }
 
 /**
