Remove certain content types from search There are certain content types such as book pages that I don't want to appear on the search results page. 
I found example code implementing this on drupal 7 here

/**
 * Implements hook_query_alter().
 * removes content types defined in the excluded_content_types array from search results
 */
function hook_query_alter(&amp;$query) {
  $is_search = FALSE;
  $excluded_content_types = array(
      'product',
      'billboard',
    );
  foreach ($query-&gt;getTables() as $table) {
    if ($table['table'] == 'search_index') {
      $is_search = TRUE;
    }
  }
  if ($is_search) {
    foreach ($excluded_content_types as $content_type) {
      $query-&gt;condition('n.type', $content_type, '&lt;&gt;');
    }
  }
}


However I want to implement this in 8.
Is there a way to exclude certain content types from search results?

UPDATE: I've also attempted to restrict the search types from within the search-result.html.twig however it does not seem like I have the content type variable available. 

{{ attach_library('classy/search-results') }}
{{ title_prefix }}

{{ dump(info_split) }}

&lt;h3{{ title_attributes.addClass('search-result__title') }}&gt;
  &lt;a href="{{ url }}"&gt;{{ title }}&lt;/a&gt;
&lt;/h3&gt;
{{ title_suffix }}
&lt;div class="search-result__snippet-info"&gt;
  {% if snippet %}
    &lt;p{{ content_attributes.addClass('search-result__snippet') }}&gt;{{ snippet }}&lt;/p&gt;
  {% endif %}
  {% if info %}
    &lt;p class="search-result__info"&gt;{{ info }}&lt;/p&gt;
  {% endif %}
&lt;/div&gt;


When performing {{ dump(info_split) }} it does not show content type as an available variable.
Configuring search is easy with Search API. Excluding node types from indexing is one of its basic config options.

https://www.drupal.org/project/search_api

When you set up your index and go to the configuration page, you can exclude bundles (types).