Site Building
Topic

Search for Drupal 7, 8, 9, and 10

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

Search in Drupal is a stable core feature. Resources related to 3rd-party software integration (like Solr) or that rely on contributed modules are subject to change.

Drupalize.Me resources

Related concepts

Drupal 8, 9, and 10
More information

Overview of cron and how it is different from Unix cron.

More information

How to run cron maintenance tasks using the core Automated Cron module, or by running them from outside the site.

Drupal 7

More information

Drupal’s built-in Search module offers powerful, flexible searching features and intelligent ranking of results. Behind the scenes, it’s silently building an index of all the words used in the site’s content. In this lesson we'll:

  • Review the Search module settings
  • Explain the importance of cron
  • Discuss searching with Views

Additional resources

Using Drupal, 2nd edition

Using Drupal source code

Drupalize.Me Guide: Using Drupal Book by O'Reilly Media

More information

In this chapter Joe covers two really important tools for most sites: cron and search. We start by explaining what cron is, and how core provides us with a basic cron tool. We also walk through how to set up your own custom cron if the core settings don't suit you. Next we look at Drupal's core search and the various ways you can configure that.

Guides

Not sure where to start? Our guides provide useful learning tracks for all skill levels.

Navigate 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.