Custom Search with Search API and Views – Drupal 8

There is an incredible module for Drupal 8 that allows you to make a custom search engine for Drupal. It is called the Search API module, it is very extensible. I will show you how to add this to your site and get it setup. I will only be covering a basic setup. There is so much more that can be done with this. It is worth taking time to reach the documentation on this page: https://www.drupal.org/project/search_api.

I did make an amateur mistake in my approach and left it in the video. I do correct myself and it became a great learning moment.

STEPS

  1. Install Search API Module: https://www.drupal.org/project/search_api
    *Make sure to uninstall the Search Module that comes with Drupal 8 if it is enabled
  2. Enable: Database Search, Database Search Defaults, Search API
    1. Adjust Database Server and Index to your website needs: admin/config/search/search-api
    2. Be sure to index the content by clicking index now: /admin/config/search/search-api/index/default_index
  3. Go to admin/structure/views add View
    1. Set a View name
    2. Change View Settings Show dropdown menu to Index Default content index *this changes according to how you name your index on the Search API page see step 2.1
    3. Checkbox make a page and set the title a slug
    4. Click Save and Edit
    5. Add to Filter Criteria:
      1. Fulltext search – Exposed to visitors 
      2. Make any other changes and click Apply
      3. Content datasource: Publishing status – click Apply
    6. Under Exposed Form set the following
      1. Exposed form in block: Yes
      2. Exposed form style settings: Change Submit button text to Search and uncheck Allow People to choose sort order and click Apply.
  4. Add fields or make other adjusts for your search results
  5. Click Save
  6. Goto: admin/structure/block
  7. Find the exposed form click Place Block in a region
  8. Click Save Blocks

Do you like coffee when you code?

Grab our coffee mug!

[products limit=”1″ columns=”1″ orderby=”date” order=”DESC” ids=”3175″]
Scroll to Top