Topic

Search

Many websites allow a user to search for text within the website using an internal search feature. Drupal core provides this with the Search module, which allows you to do a keyword search on content (text in nodes, taxonomy, etc.) and users (by name or email). In addition to having a search box to enter a keyword query into, you also have a results page, which lists the content or users that match, or a "no results" message if none match.

A search engine works by indexing your site so that it knows all of the words available and what content or users they are associated with. This needs to be updated periodically to remain accurate. Updating is most often achieved using a server utility called cron.

If Drupal core's search is not sufficient for your needs, there are many search engines you can integrate. The most popular choice by far in Drupal is to use Apache Solr in combination with the contributed Search API module. We recommend using Search API instead of the core Search module in most cases.

Example tasks

  • Search for a keyword on the site.
  • Change the relative importance of various factors to make some results appear higher than others.
  • Configure how your content is indexed.
  • Configure a cron task to keep your search index up-to-date

Confidence

This is a stable core feature without significant changes since 8.0.

Drupalize.Me resources

From the Drupal 8 User Guide, configuring cron:

More Guides

We have guides on many Drupal skills and topics.

Explore guides

External resources

  • Search module overview (drupal.org)
    • Community documentation about the core Search module.
  • Search API (drupal.org)
    • Official documentation for the Search API module is well maintained and thorough.
    • A solid guide for using Solr with Search API and Search API Solr.
  • Setting up Faceted Apache Solr search in Drupal 8 (jeffgeerling.com)
    • This is a blog post and video that explains what faceted search is and how to add that feature to your site with Apache Solr.
  • Webinar: How to Build Custom Search Pages in Drupal 8 (youtube.com)
    • Looks at creating custom search pages with Drupal core search module, as well as installing and using Search API to gain more control over custom search pages.