Complete Setup for Drupal Search API Solr: The Complete Setup & Optimization Guide

Mayur Upadhyay
Mayur Upadhyay
drupal search api solr

When you’re managing a Drupal site with large or complex content structures, having a fast and customizable search solution becomes essential. Drupal’s core search is limited and doesn’t scale well.

That’s where Apache Solr comes into play. By integrating it with Drupal’s Search API module, you can achieve high-performance, full-text search with filters, facets, and more.

This guide explains the exact implementation path that connects Solr with Drupal through the Search API, ensuring developers can create scalable and precise search experiences without the usual guesswork.

What is Apache Solr?

Apache Solr is an open-source, enterprise-grade search platform built on a Java-based search library called Apache Lucene. Solr provides powerful full-text search, faceted navigation, hit highlighting, and advanced indexing capabilities. That makes it ideal for building scalable, high-performance search applications.

Key Features of Apache Solr

  • Powerful Full-Text Search: Advanced querying, fuzzy matching, phrase search, and multilingual support.
  • Scalable & Distributed (SolrCloud): Horizontal scaling, sharding, and high availability.
  • Faceted Search & Filtering: Dynamic categorization (e.g., price ranges, tags).
  • Near Real-Time Indexing: Fast updates with minimal delay.
  • Rich Document Support: Handles JSON, XML, CSV, PDFs, Word, and more.
  • REST API & Easy Integration: Works with Hadoop, Spark, and databases.
  • Geospatial Search: Location-based queries (e.g., “near me”).

Solr is widely used by organizations like Netflix, eBay, and Instagram for fast, scalable search capabilities. If you want features like full-text search and faceted navigation through this Solr library, our professional Drupal development company will be suitable.

Install Apache Solr (Locally or on Server)

To begin, you need a running instance of Apache Solr. You can either install it manually on a server or run it using Docker.

A. Using Docker (Quick Setup)

This is ideal for local development.

docker run -d -p 8983:8983 --name solr solr
docker exec -it solr solr create_core -c drupal

You’ll now have a core named drupal running on http://localhost:8983/solr/drupal.

B. Manual Installation (For VPS/Production)

sudo apt update
sudo apt install solr
sudo su - solr -c "/opt/solr/bin/solr create -c drupal"

Once installed, make sure the Solr core is accessible and ready to accept schema configurations.

With Solr up and running, the next step is to prepare it to communicate with Drupal using the right schema and config files.

Configure Solr Schema for Drupal

Solr needs specific schema files that align with the way Drupal indexes content. The search_api_solr module provides these schema files.

Steps to Configure:

1. Locate Drupal Solr Configs
Navigate to: 

modules/contrib/search_api_solr/solr-conf/8.x/

2. Copy to Solr Core
Replace the contents of your Solr core’s config folder with Drupal’s config:

cp -r solr-conf/8.x/* /var/solr/data/drupal/conf/

3. Restart Solr

sudo service solr restart

4. Verify
Go to Solr Admin > drupal core > Schema to confirm the fields are recognized.

Now your Solr setup is tailored to understand Drupal content and is schema-ready for integration.

Install Required Drupal Modules

To bridge Drupal with Solr, you’ll need a few key modules installed.

Install via Composer

composer require drupal/search_api drupal/search_api_solr

(Optional: For document indexing like PDFs, also add drupal/search_api_attachments.)

Enable Modules

drush en search_api search_api_solr

This enables the backend connector between Drupal’s Search API and Solr.

Once these modules are active, your Drupal site can now recognize and talk to the Solr server — making configuration the next logical step.

Create and Configure Search API Index

After setup, you’ll create a search server and index in the Drupal admin panel.

Create a Search Server

  • Go to Configuration → Search API → Add Server
  • Choose “Solr” as the backend
  • Enter the Solr core URL (e.g., http://localhost:8983/solr/drupal)
  • Save and Test Connection

Create an Index

  • Add new index targeting “Content”
  • Choose bundles like Articles or Pages
  • Add required fields (title, body, tags, etc.)
  • Select processors: HTML filter, language, stopwords, etc.

Index Your Content

Run cron or use Drush:

drush search-api:index

Your Drupal content is now indexed in Solr. With this, you’ve achieved the functional connection and indexing pipeline. Next, we make it usable and user-friendly. If you want help with that, hire our Drupal developers. For DIY, follow along.

Tips to Build Frontend Search & Customize Experience

Now that indexing is working, it’s time to present the search to users in a clean and powerful way.

Optimize Search UI Components (Views or Facets)

Leverage Solr’s faceted search to create dynamic filters (e.g., price ranges, categories, tags) in Drupal Views. Use Facet API modules like “Facets Pretty Paths” for SEO-friendly URLs (e.g., /search/category:books/price:10-20).

Group related facets into collapsible sections to reduce clutter and improve usability.

Improve Relevance & Ranking

Tweak Solr’s “edismax” query parser to prioritize exact matches, popular content, or recent updates. Use “boosting” rules (e.g., higher weight for product names vs. descriptions). Implement “pinned” results for promoted items (like featured products).

Test with “Solr’s debugQuery” to fine-tune scoring.

Integrate “Search API Autocomplete” or “React.js” for real-time suggestions. Use Drupal’s AJAX to update facets & results dynamically. Add subtle animations (like fade-in effects) for smoother transitions. Optimize performance by debouncing input (delaying queries until typing pauses).

Customize Result Display

Use Drupal’s View Modes to display different layouts (grid, list, map). Highlight matched keywords with “highlighting snippets” (via Solr’s hl feature). Add thumbnails, ratings, or stock status for eCommerce.

For zero-results, suggest “Did You Mean?” corrections or popular searches.

Want help with your Drupal project?

FAQs for Drupal Search API Solr

Can I use Solr with multilingual content in Drupal?

Yes, Solr supports language-specific analyzers, and the Search API lets you configure separate processors for each language.

What happens if the Solr core URL is incorrect?

Drupal will fail to connect, and you’ll see a “Could not connect to Solr server” error on the admin interface. Always test the connection after configuration.

Can I customize the way search results are ranked?

Absolutely. You can boost certain fields during index setup, or use hook_search_api_solr_query_alter() to programmatically adjust query parameters.

Is this setup compatible with headless or decoupled Drupal?

Yes, you can expose Solr-backed search endpoints through custom APIs or JSON:API and consume them in any frontend.

How do I secure my Solr instance in production?

Use firewall rules, IP whitelisting, and basic auth for Solr admin access. Avoid exposing Solr directly to the public.

Let’s Summarize

Drupal’s Search API Solr integration brings the power of Apache Solr’s lightning-fast, scalable search to your website. That means advanced features like faceted navigation, intelligent relevancy ranking, and near real-time indexing.

You need to optimize search UI components, fine-tune Solr’s query handling, and enhance UX with AJAX-driven interactions. That will help create a search experience that feels intuitive, responsive, and tailored to your users’ needs.

For more advanced setups or custom implementation, connect with our Drupal experts today!

author
Mayur Upadhyay is a tech professional with expertise in Shopify, WordPress, Drupal, Frameworks, jQuery, and more. With a proven track record in web development and eCommerce development.

Related Blog Posts

Drupal Symfony Mailer

The Drupal Symfony Mailer system offers a flexible and modern way to handle email sending in Drupal. From basic configuration to templated messages and third-party...

drupal cdn

Using a CDN with your Drupal site can dramatically improve speed, performance, and security. It reduces load times, handles traffic spikes, and lowers server stress...

drupal coding standards

Drupal coding standards help developers write clean, consistent, and secure code across PHP, JavaScript, CSS, and Twig. Following these guidelines makes teamwork smoother, reduces errors,...