diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php
index 733db53ac7026bca694913a18fb90d166af5d043..a9ab5a1861bbd517cabfed5519dfb8655593e83f 100644
--- a/core/modules/views/src/Plugin/views/filter/StringFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
@@ -288,7 +288,7 @@ protected function opContainsWord($field) {
       }
     }
 
-    if (!$where) {
+    if ($where->count() === 0) {
       return;
     }
 
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
index 9ad0f88f633029a681abf84daa75dc8958ee8452..c24cc6ff03487aa06be606cd85f3697a7a48fad2 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
@@ -293,6 +293,42 @@ public function testFilterStringWord() {
       ],
     ];
     $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
+    $view->destroy();
+
+    $view = Views::getView('test_view');
+    $view->setDisplay();
+
+    // Change the filtering to a sting containing only illegal characters.
+    $view->displayHandlers->get('default')->overrideOption('filters', [
+      'description' => [
+        'id' => 'description',
+        'table' => 'views_test_data',
+        'field' => 'description',
+        'relationship' => 'none',
+        'operator' => 'allwords',
+        'value' => ':-)',
+      ],
+    ]);
+
+    $this->executeView($view);
+    $resultset = [
+      [
+        'name' => 'Ringo',
+      ],
+      [
+        'name' => 'John',
+      ],
+      [
+        'name' => 'George',
+      ],
+      [
+        'name' => 'Paul',
+      ],
+      [
+        'name' => 'Meredith',
+      ],
+    ];
+    $this->assertIdenticalResultset($view, $resultset);
   }