The search module within Drupal 8 is very basic. Best bet is to disable the search core module and enable the Search API module. This module provides a framework for easily creating searches on any entity known to Drupal, using any kind of search engine. For site administrators, it is a great alternative to other search solutions, since it already incorporates facetting support and the ability to use the Views module for displaying search results, filters, etc. Also, with the Apache Solr integration, a high-performance search engine is available for this module.
In this article I discuss how to set up a site search using the Search API module, Views module and storing the search in the database. For more advanced search setup Apache Solr can be used. Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene. For this tutorial we will use the default which is storing the search index in the database.
Step 1: enabled the search API module, make sure you also disable the core search module.
Step 2: Create a search server.
We need to define a server that will store the index data. The default is to use the database. On adminmenu goto Configuration > Search and Meta > Search API. Click add server.
Step 3. Setup an index.
Click add index. The important bits here are the content and that we assocaite the index with the database server we just created.
Step 4: Run the index.
Step 5: Create the search results page using views, and exposed the search from the view as a block.
We have the content indexed and stored in the database. We now need to be able to use it. Create a new view, but specify the search index as the source of the views content.
There are 2 key parts of the view we need to define. We need to define a filter which is a full search. And we need to expose this form in a block.
If we save the view now, we can go to the blocks section and find out search block. This will display a search on the site which will then use the view as the search results.
All done, used Search API and views to create a nice site search.
Add new comment