diff --git src/wp-includes/query.php src/wp-includes/query.php
index d53ec42..3703428 100644
--- src/wp-includes/query.php
+++ src/wp-includes/query.php
@@ -2268,7 +2268,7 @@ class WP_Query {
 				$like = '%' . $wpdb->esc_like( $q['s'] ) . '%';
 			}
 
-			$search_orderby = '(CASE ';
+			$search_orderby = '';
 
 			// sentence match in 'post_title'
 			if ( $like ) {
@@ -2289,7 +2289,10 @@ class WP_Query {
 			if ( $like ) {
 				$search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_content LIKE %s THEN 4 ", $like );
 			}
-			$search_orderby .= 'ELSE 5 END)';
+
+			if ( $search_orderby ) {
+				$search_orderby = '(CASE ' . $search_orderby . 'ELSE 5 END)';
+			}
 		} else {
 			// single word or sentence search
 			$search_orderby = reset( $q['search_orderby_title'] ) . ' DESC';
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index caf862c..5fe6d5e 100644
--- tests/phpunit/tests/query/search.php
+++ tests/phpunit/tests/query/search.php
@@ -125,4 +125,16 @@ class Tests_Query_Search extends WP_UnitTestCase {
 
 		$this->assertEqualSets( array( $p3 ), $q->posts );
 	}
+
+	/**
+	 * @ticket 35361
+	 */
+	public function test_search_orderby_should_be_empty_when_search_string_is_longer_than_6_words_and_exclusion_operator_is_used() {
+		$q = new WP_Query( array(
+			's' => 'foo1 foo2 foo3 foo4 foo5 foo6 foo7 -bar',
+			'fields' => 'ids',
+		) );
+
+		$this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
+	}
 }
