Development

Drupal Search API — search that actually works

Search is often the most-used feature of a site — and the most often done poorly. Here is how to set it up properly in Drupal.

Drupal Core includes a basic search function built on MySQL full-text search. This works for a few hundred pages. But when a site has thousands of content items, multilingual content, complex filters and autocomplete suggestions — a different solution is needed.

Search API module

Search API is Drupal's de facto standard for advanced search. It decouples the search index from the database and allows using external search engines.

Search API provides:

  • Indexing — define which content types and fields are indexed
  • Server abstraction — the same configuration works with Solr, Elasticsearch or database search
  • Views integration — search results displayed via Drupal Views, with filters and sorting
  • Facets supportsearch_api_solr with the facets module delivers filtered category search

Apache Solr

Apache Solr is a Java-based search server with the closest Drupal integration.

When to use Solr:

  • Large content volume (10,000+ documents)
  • Multilingual search with language-specific stemming
  • Complex faceted search (filters, ranges, relevance tuning)
  • Fast autocomplete suggestions

The official search_api_solr module handles indexing, queries and language stemming automatically.

Elasticsearch

Elasticsearch is an alternative to Solr — more powerful for real-time search and large-scale data analysis.

When to use Elasticsearch:

  • Real-time search (logs, events, dynamic content)
  • Geographic queries (nearby locations)
  • Complex data analytics and aggregations

Drupal has an elasticsearch_connector module, though it is less actively maintained than the Solr integration.

Database server — the simpler option

Search API also supports using Drupal's own database as the search backend. This does not scale to thousands of documents, but for smaller sites it is a simpler solution without an external server.

Typical search requirements

NeedSolution
Simple text search, small siteSearch API + Database server
Fast search + filters, medium siteSearch API + Solr
Real-time indexes, large dataSearch API + Elasticsearch
Autocomplete suggestionsSearch API + Solr + search_api_autocomplete

If search is a critical feature of your site, the search architecture is worth designing before development starts — retrofitting it later is costly. Describe your requirements.

Kaido Toomingas Kaido Toomingas WebPro Company OÜ

Need Drupal help?

If the article describes your situation, you do not have to read everything first. A real person will help you choose the next step.