title: Exclude posts from search results based on a meta_query with "NOT EXISTS" doesn't work anymore
body: <p>I have registered a meta box inside posts and pages with a check box to prevent that post/page from being shown in the search results. Once the user checks on that check box and hits save/update the post, a meta key called <code>_dont_show_in_search_results</code> with value <code>POST_ID</code> will be saved into the database associated with that post.</p>
  
  <p>Inside <code>pre_get_posts</code> action, I'm doing the following:</p>
  
  <pre><code>function exclude_posts_from_search( $query ){
     if($query-&gt;is_main_query() &amp;&amp; is_search() ){
       $query-&gt;set('meta_query', array(array("key"=&gt;"_dont_show_in_search_results", "compare"=&gt;"NOT EXISTS")));
     }
  }
  
  add_action('pre_get_posts','exclude_posts_from_search');
  </code></pre>
  
  <p>It used to work in the past, but not sure what happened for that query as now it doesn't show any results on the search page!</p>
  
  <p>The WordPress version I'm using is <code>5.2.3</code>. Seems this issue has been reported many times as bugs, <a href="https://core.trac.wordpress.org/ticket/18158" rel="nofollow noreferrer">here</a> and <a href="https://core.trac.wordpress.org/ticket/23268" rel="nofollow noreferrer">here</a>.</p>
  
  <p>If I tried to print the query, it shows like this:</p>
  
  <pre><code>object(WP_Query)[566]
    public 'query' =&gt; 
      array (size=1)
        's' =&gt; string 'searchTerm' (length=10)
    public 'query_vars' =&gt; 
      array (size=53)
        's' =&gt; string 'searchTerm' (length=10)
        'error' =&gt; string '' (length=0)
        'm' =&gt; string '' (length=0)
        'p' =&gt; int 0
        'post_parent' =&gt; string '' (length=0)
        'subpost' =&gt; string '' (length=0)
        'subpost_id' =&gt; string '' (length=0)
        'attachment' =&gt; string '' (length=0)
        'attachment_id' =&gt; int 0
        'name' =&gt; string '' (length=0)
        'static' =&gt; string '' (length=0)
        'pagename' =&gt; string '' (length=0)
        'page_id' =&gt; int 0
        'second' =&gt; string '' (length=0)
        'minute' =&gt; string '' (length=0)
        'hour' =&gt; string '' (length=0)
        'day' =&gt; int 0
        'monthnum' =&gt; int 0
        'year' =&gt; int 0
        'w' =&gt; int 0
        'category_name' =&gt; string '' (length=0)
        'tag' =&gt; string '' (length=0)
        'cat' =&gt; string '' (length=0)
        'tag_id' =&gt; string '' (length=0)
        'author' =&gt; string '' (length=0)
        'author_name' =&gt; string '' (length=0)
        'feed' =&gt; string '' (length=0)
        'tb' =&gt; string '' (length=0)
        'paged' =&gt; int 0
        'meta_key' =&gt; string '' (length=0)
        'meta_value' =&gt; string '' (length=0)
        'preview' =&gt; string '' (length=0)
        'sentence' =&gt; string '' (length=0)
        'title' =&gt; string '' (length=0)
        'fields' =&gt; string '' (length=0)
        'menu_order' =&gt; string '' (length=0)
        'embed' =&gt; string '' (length=0)
        'category__in' =&gt; 
          array (size=0)
            empty
        'category__not_in' =&gt; 
          array (size=0)
            empty
        'category__and' =&gt; 
          array (size=0)
            empty
        'post__in' =&gt; 
          array (size=0)
            empty
        'post__not_in' =&gt; 
          array (size=0)
            empty
        'post_name__in' =&gt; 
          array (size=0)
            empty
        'tag__in' =&gt; 
          array (size=0)
            empty
        'tag__not_in' =&gt; 
          array (size=0)
            empty
        'tag__and' =&gt; 
          array (size=0)
            empty
        'tag_slug__in' =&gt; 
          array (size=0)
            empty
        'tag_slug__and' =&gt; 
          array (size=0)
            empty
        'post_parent__in' =&gt; 
          array (size=0)
            empty
        'post_parent__not_in' =&gt; 
          array (size=0)
            empty
        'author__in' =&gt; 
          array (size=0)
            empty
        'author__not_in' =&gt; 
          array (size=0)
            empty
        'meta_query' =&gt; 
          array (size=1)
            0 =&gt; 
              array (size=2)
                'key' =&gt; string '_dont_show_in_search_results' (length=28)
                'compare' =&gt; string 'NOT EXISTS' (length=10)
    public 'tax_query' =&gt; 
      object(WP_Tax_Query)[1650]
        public 'queries' =&gt; 
          array (size=0)
            empty
        public 'relation' =&gt; string 'AND' (length=3)
        protected 'table_aliases' =&gt; 
          array (size=0)
            empty
        public 'queried_terms' =&gt; 
          array (size=0)
            empty
        public 'primary_table' =&gt; null
        public 'primary_id_column' =&gt; null
    public 'meta_query' =&gt; boolean false
    public 'date_query' =&gt; boolean false
    public 'post_count' =&gt; int 0
    public 'current_post' =&gt; int -1
    public 'in_the_loop' =&gt; boolean false
    public 'comment_count' =&gt; int 0
    public 'current_comment' =&gt; int -1
    public 'found_posts' =&gt; int 0
    public 'max_num_pages' =&gt; int 0
    public 'max_num_comment_pages' =&gt; int 0
    public 'is_single' =&gt; boolean false
    public 'is_preview' =&gt; boolean false
    public 'is_page' =&gt; boolean false
    public 'is_archive' =&gt; boolean false
    public 'is_date' =&gt; boolean false
    public 'is_year' =&gt; boolean false
    public 'is_month' =&gt; boolean false
    public 'is_day' =&gt; boolean false
    public 'is_time' =&gt; boolean false
    public 'is_author' =&gt; boolean false
    public 'is_category' =&gt; boolean false
    public 'is_tag' =&gt; boolean false
    public 'is_tax' =&gt; boolean false
    public 'is_search' =&gt; boolean true
    public 'is_feed' =&gt; boolean false
    public 'is_comment_feed' =&gt; boolean false
    public 'is_trackback' =&gt; boolean false
    public 'is_home' =&gt; boolean false
    public 'is_privacy_policy' =&gt; boolean false
    public 'is_404' =&gt; boolean false
    public 'is_embed' =&gt; boolean false
    public 'is_paged' =&gt; boolean false
    public 'is_admin' =&gt; boolean false
    public 'is_attachment' =&gt; boolean false
    public 'is_singular' =&gt; boolean false
    public 'is_robots' =&gt; boolean false
    public 'is_posts_page' =&gt; boolean false
    public 'is_post_type_archive' =&gt; boolean false
    private 'query_vars_hash' =&gt; string '0d61505a07baa4860f1831a27ad01416' (length=32)
    private 'query_vars_changed' =&gt; boolean false
    public 'thumbnails_cached' =&gt; boolean false
    private 'stopwords' =&gt; null
    private 'compat_fields' =&gt; 
      array (size=2)
        0 =&gt; string 'query_vars_hash' (length=15)
        1 =&gt; string 'query_vars_changed' (length=18)
    private 'compat_methods' =&gt; 
      array (size=2)
        0 =&gt; string 'init_query_flags' (length=16)
        1 =&gt; string 'parse_tax_query' (length=15)
  </code></pre>