diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
index 771976f..938dc96 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
@@ -65,8 +65,16 @@ function testSearchText() {
     // the Denial-of-Service protection.
     $limit = \Drupal::config('search.settings')->get('and_or_limit');
     $keys = array();
+    $done = FALSE;
     for ($i = 0; $i < $limit + 1; $i++) {
-      $keys[] = $this->randomName(3);
+      if ($i % 2 == 0 && !$done && $i > 1) {
+        $done = TRUE;
+        $keys[] = 'AND';
+      }
+      else {
+        $keys[] = $this->randomName(3);
+      }
+
       if ($i % 2 == 0) {
         $keys[] = 'OR';
       }
