A step-by-step guide covering installation, configuration, modules, and performance tuning.
The default Drupal search uses your database, which is fine for small sites but becomes slow and CPU-hungry as content grows. Apache Solr is a dedicated search engine that handles full-text search, filters, facets, spellcheck and relevance ranking far better, and it moves search load away from MySQL. In this guide you will learn how to connect Drupal to Solr, from the first install to advanced tuning.
How Drupal and Solr Work Together
Three pieces are involved:
- Drupal holds your content (nodes, users, files, commerce products and so on).
- Search API is the Drupal framework that defines what gets indexed and how searching works.
- Solr stores the search index and answers queries. The Search API Solr module is the bridge between the two.
The flow is simple: content is saved in Drupal, Search API tracks it, then sends it to Solr during indexing. When a visitor searches, Drupal sends the query to Solr and shows the results.
Modules You Will Use
| Module | Purpose |
|---|---|
Search API (search_api) | Core framework for indexes, servers and search pages |
Search API Solr (search_api_solr) | Solr connector, config set generation, Solr-specific features |
Facets (facets) | Filter blocks such as category, date, author |
Search API Autocomplete (search_api_autocomplete) | Suggestions while the user types |
Search API Solr Admin (search_api_solr_admin) | Admin tools to manage Solr cores and config from Drupal |
| Views (core) | Builds the search results page |
| Drush | Command-line indexing and maintenance |
Level 1: Basic Setup
Step 1: Install Solr on your server
Solr needs Java (a current LTS release such as 17). Download Solr from the official Apache site, extract it, and start it:
tar xzf solr-9.x.x.tgz
cd solr-9.x.x
bin/solr start
By default the admin panel runs at http://localhost:8983/solr. Check the Search API Solr module page for the Solr versions supported by the release you install.
Step 2: Install the Drupal modules
composer require drupal/search_api_solr
drush en search_api search_api_solr -y
This also pulls in the Search API module as a dependency.
Step 3: Create the Solr core and config set
The Solr configuration must match the Drupal index fields, so Drupal generates it for you. First add the server in Drupal (step 4), then download the config set:
drush search-api-solr:get-server-config my_solr_server /tmp/solr-config.zip
Unzip it and create the core using that config:
unzip /tmp/solr-config.zip -d /tmp/solr-conf
bin/solr create -c drupal_core -d /tmp/solr-conf
You can also download the same zip from the server page in Drupal (Configuration → Search and metadata → Search API → your server → Get config.zip).
Step 4: Add the Solr server in Drupal
Go to Configuration → Search and metadata → Search API → Add server.
- Server name: My Solr Server
- Backend: Solr
- Solr connector: Standard (use Basic Auth if your Solr is protected)
- Host: localhost
- Port: 8983
- Path: /
- Core: drupal_core
Save and confirm the connection shows as successful.
Step 5: Create an index
Go to Add index and fill in:
- Name: Content index
- Data source: Content (choose the content types you want searchable)
- Server: the Solr server you just created
- Index items immediately: enabled for small sites, disabled for large sites (use cron or Drush instead)
Then open the Fields tab and add the fields to index, such as Title, Body, Tags, Author and Created date. Set Title and Body as Fulltext fields and give Title a higher boost.
Step 6: Index your content
Use the Index page in the admin UI, or Drush:
drush search-api:index
drush search-api:status
The status command shows how many items are indexed versus the total.
Step 7: Build a search page with Views
Create a new View, choose your Search API index as the data source, and add:
- A page with a path such as
/search - An exposed fulltext search filter
- Fields or a display mode for the results
Visit /search, run a query, and you now have Solr-powered search.
Level 2: Intermediate Configuration
Processors
Processors clean and prepare data before it reaches Solr. Under your index’s Processors tab, useful options include:
- HTML filter: strips markup from body text
- Ignore case and Tokenizer
- Stopwords: removes common words such as “the” and “and”
- Stemmer: matches “running” with “run”
- Highlighting: shows matched words in result snippets
- Content access: respects node access so users only find content they may view
- Entity status and Language-specific fields
Field types and boosts
Choose the right data type for each field: Fulltext for searchable text, String for exact matches and facets, Integer or Date for sorting and ranges. Boost important fields (for example Title 5.0, Body 1.0) so relevant content ranks higher.
Add facets
composer require drupal/facets
drush en facets -y
Go to Configuration → Search and metadata → Facets → Add facet, choose your search view as the facet source, pick a field (for example Content type or Tags), and place the facet block in a sidebar region. Index fields used for facets should be String or Integer types.
Add autocomplete
composer require drupal/search_api_autocomplete
drush en search_api_autocomplete -y
Enable autocomplete for your search view and Solr will suggest terms while the user types. The Search API Solr package also includes Solr-specific suggesters for better suggestions.
Cron and batch settings
On the index edit page, set Cron batch size to a sensible number (for example 50 to 200) and make sure real system cron runs drush core:cron. This keeps indexing out of visitor page requests.
Level 3: Advanced Features
Multilingual sites
Search API Solr supports language-specific field types, so each language gets its own stemming and stopwords. After adding languages or changing field types, regenerate and re-upload the config set, then reload the core:
drush search-api-solr:get-server-config my_solr_server /tmp/solr-config.zip
Always regenerate the config set after changing indexed fields, adding languages, or upgrading the module.
Spellcheck and “Did you mean”
Enable spellcheck in the Solr backend settings and in your View. Drupal can then show suggestions for misspelled queries.
Highlighting and snippets
Enable the Highlighting processor on the index and enable excerpts in the Solr backend settings so Solr returns the matching text fragments.
Boosting and relevance tuning
- Raise boosts on Title and key taxonomy fields
- Boost recent content by adding a date-based boost processor or custom Solr function
- Use the Search API Solr advanced settings to tune
mm(minimum match) and query parser behavior
Searching files and attachments
Search API Solr can index text extracted from files such as PDFs and Word documents through Solr’s extraction feature, so attachments become searchable along with your content.
Multiple indexes
Use separate indexes for different content, for example one for articles and one for products, and combine them with a single search view or use separate views for each. Several indexes can share one Solr server.
Custom indexing with code
You can add computed fields through a Search API Processor plugin, for example to index a combined “search summary” or data from referenced entities. Implement the plugin in a custom module and enable it on the index.
Level 4: Performance, Security and Production
Reindex and maintenance commands
drush search-api:status
drush search-api:index
drush search-api:reset-tracker
drush search-api:clear
drush search-api:rebuild-tracker
Use reset-tracker followed by index to reindex everything, and clear to empty an index in Solr.
Keep indexing fast and light
- Index only the fields and content types you really need
- Avoid indexing very large, rarely used fields
- Run indexing from Drush or cron, not on page requests
- Give Solr enough heap memory (set
SOLR_HEAPinsolr.in.sh) and monitor it - Tune
autoCommitandautoSoftCommitinsolrconfig.xmlso you do not commit after every document
Secure your Solr
- Never expose port 8983 to the public internet
- Bind Solr to localhost or a private network, or restrict it with a firewall
- Enable authentication (Basic Auth) and enter the credentials in the Drupal Solr connector
- Run Solr as its own non-root user
Scaling with SolrCloud
For large or high-availability setups, run SolrCloud with ZooKeeper, multiple shards and replicas. Search API Solr includes a SolrCloud connector so Drupal can work with collections instead of single cores.
Monitoring
Watch the Solr admin dashboard for heap usage, query times and cache hit rates, and use tools such as Prometheus or Grafana for long-term trends. Check the Drupal status report and Search API status page for indexing errors.
Common Problems and Fixes
| Problem | Likely cause and fix |
|---|---|
| Server shows “not available” | Solr not running, wrong host, port or core name, or firewall blocking |
| Fields missing or errors on indexing | Config set is outdated. Regenerate and re-upload, then reload the core |
| No results for new content | Item not indexed yet. Run drush search-api:index and check cron |
| Facets show wrong values | Field type should be String or Integer, not Fulltext |
| Search is slow | Too many fields, small Solr heap, or bad commit settings |
| Results show unpublished content | Enable the Content access and Entity status processors |
| Indexing is stuck | Check watchdog and Solr logs for a failing item, then reset the tracker |
Quick Implementation Checklist
- Install Java and Solr, and start it
composer require drupal/search_api_solrand enable the modules- Add the Solr server in Drupal
- Generate the config set, create the Solr core with it
- Create the index, choose fields and processors
- Index content with Drush
- Build the search View
- Add Facets and Autocomplete
- Secure Solr and set up cron
- Monitor, tune and regenerate config after changes
Final Thoughts
Solr turns Drupal search from a slow database feature into a fast, flexible search experience, and it reduces the load on your main database and CPU. Start with the basics, get a working index and search page, then add facets, autocomplete and tuning as your site grows. Always keep the Solr config set in sync with your Drupal index, secure the server, and run indexing from cron or Drush.
Need help setting up Solr search on your Drupal project? Get in touch and we can plan the right setup for your site.
A step-by-step guide covering installation, configuration, modules, and performance tuning.
The default Drupal search uses your database, which is fine for small sites but becomes slow and CPU-hungry as content grows. Apache Solr is a dedicated search engine that handles full-text search, filters, facets, spellcheck and relevance ranking far better, and it moves search load away from MySQL. In this guide you will learn how to connect Drupal to Solr, from the first install to advanced tuning.
How Drupal and Solr Work Together
Three pieces are involved:
- Drupal holds your content (nodes, users, files, commerce products and so on).
- Search API is the Drupal framework that defines what gets indexed and how searching works.
- Solr stores the search index and answers queries. The Search API Solr module is the bridge between the two.
The flow is simple: content is saved in Drupal, Search API tracks it, then sends it to Solr during indexing. When a visitor searches, Drupal sends the query to Solr and shows the results.
Modules You Will Use
| Module | Purpose |
|---|---|
Search API (search_api) | Core framework for indexes, servers and search pages |
Search API Solr (search_api_solr) | Solr connector, config set generation, Solr-specific features |
Facets (facets) | Filter blocks such as category, date, author |
Search API Autocomplete (search_api_autocomplete) | Suggestions while the user types |
Search API Solr Admin (search_api_solr_admin) | Admin tools to manage Solr cores and config from Drupal |
| Views (core) | Builds the search results page |
| Drush | Command-line indexing and maintenance |
Level 1: Basic Setup
Step 1: Install Solr on your server
Solr needs Java (a current LTS release such as 17). Download Solr from the official Apache site, extract it, and start it:
tar xzf solr-9.x.x.tgz
cd solr-9.x.x
bin/solr start
By default the admin panel runs at http://localhost:8983/solr. Check the Search API Solr module page for the Solr versions supported by the release you install.
Step 2: Install the Drupal modules
composer require drupal/search_api_solr
drush en search_api search_api_solr -y
This also pulls in the Search API module as a dependency.
Step 3: Create the Solr core and config set
The Solr configuration must match the Drupal index fields, so Drupal generates it for you. First add the server in Drupal (step 4), then download the config set:
drush search-api-solr:get-server-config my_solr_server /tmp/solr-config.zip
Unzip it and create the core using that config:
unzip /tmp/solr-config.zip -d /tmp/solr-conf
bin/solr create -c drupal_core -d /tmp/solr-conf
You can also download the same zip from the server page in Drupal (Configuration → Search and metadata → Search API → your server → Get config.zip).
Step 4: Add the Solr server in Drupal
Go to Configuration → Search and metadata → Search API → Add server.
- Server name: My Solr Server
- Backend: Solr
- Solr connector: Standard (use Basic Auth if your Solr is protected)
- Host: localhost
- Port: 8983
- Path: /
- Core: drupal_core
Save and confirm the connection shows as successful.
Step 5: Create an index
Go to Add index and fill in:
- Name: Content index
- Data source: Content (choose the content types you want searchable)
- Server: the Solr server you just created
- Index items immediately: enabled for small sites, disabled for large sites (use cron or Drush instead)
Then open the Fields tab and add the fields to index, such as Title, Body, Tags, Author and Created date. Set Title and Body as Fulltext fields and give Title a higher boost.
Step 6: Index your content
Use the Index page in the admin UI, or Drush:
drush search-api:index
drush search-api:status
The status command shows how many items are indexed versus the total.
Step 7: Build a search page with Views
Create a new View, choose your Search API index as the data source, and add:
- A page with a path such as
/search - An exposed fulltext search filter
- Fields or a display mode for the results
Visit /search, run a query, and you now have Solr-powered search.
Level 2: Intermediate Configuration
Processors
Processors clean and prepare data before it reaches Solr. Under your index’s Processors tab, useful options include:
- HTML filter: strips markup from body text
- Ignore case and Tokenizer
- Stopwords: removes common words such as “the” and “and”
- Stemmer: matches “running” with “run”
- Highlighting: shows matched words in result snippets
- Content access: respects node access so users only find content they may view
- Entity status and Language-specific fields
Field types and boosts
Choose the right data type for each field: Fulltext for searchable text, String for exact matches and facets, Integer or Date for sorting and ranges. Boost important fields (for example Title 5.0, Body 1.0) so relevant content ranks higher.
Add facets
composer require drupal/facets
drush en facets -y
Go to Configuration → Search and metadata → Facets → Add facet, choose your search view as the facet source, pick a field (for example Content type or Tags), and place the facet block in a sidebar region. Index fields used for facets should be String or Integer types.
Add autocomplete
composer require drupal/search_api_autocomplete
drush en search_api_autocomplete -y
Enable autocomplete for your search view and Solr will suggest terms while the user types. The Search API Solr package also includes Solr-specific suggesters for better suggestions.
Cron and batch settings
On the index edit page, set Cron batch size to a sensible number (for example 50 to 200) and make sure real system cron runs drush core:cron. This keeps indexing out of visitor page requests.
Level 3: Advanced Features
Multilingual sites
Search API Solr supports language-specific field types, so each language gets its own stemming and stopwords. After adding languages or changing field types, regenerate and re-upload the config set, then reload the core:
drush search-api-solr:get-server-config my_solr_server /tmp/solr-config.zip
Always regenerate the config set after changing indexed fields, adding languages, or upgrading the module.
Spellcheck and “Did you mean”
Enable spellcheck in the Solr backend settings and in your View. Drupal can then show suggestions for misspelled queries.
Highlighting and snippets
Enable the Highlighting processor on the index and enable excerpts in the Solr backend settings so Solr returns the matching text fragments.
Boosting and relevance tuning
- Raise boosts on Title and key taxonomy fields
- Boost recent content by adding a date-based boost processor or custom Solr function
- Use the Search API Solr advanced settings to tune
mm(minimum match) and query parser behavior
Searching files and attachments
Search API Solr can index text extracted from files such as PDFs and Word documents through Solr’s extraction feature, so attachments become searchable along with your content.
Multiple indexes
Use separate indexes for different content, for example one for articles and one for products, and combine them with a single search view or use separate views for each. Several indexes can share one Solr server.
Custom indexing with code
You can add computed fields through a Search API Processor plugin, for example to index a combined “search summary” or data from referenced entities. Implement the plugin in a custom module and enable it on the index.
Level 4: Performance, Security and Production
Reindex and maintenance commands
drush search-api:status
drush search-api:index
drush search-api:reset-tracker
drush search-api:clear
drush search-api:rebuild-tracker
Use reset-tracker followed by index to reindex everything, and clear to empty an index in Solr.
Keep indexing fast and light
- Index only the fields and content types you really need
- Avoid indexing very large, rarely used fields
- Run indexing from Drush or cron, not on page requests
- Give Solr enough heap memory (set
SOLR_HEAPinsolr.in.sh) and monitor it - Tune
autoCommitandautoSoftCommitinsolrconfig.xmlso you do not commit after every document
Secure your Solr
- Never expose port 8983 to the public internet
- Bind Solr to localhost or a private network, or restrict it with a firewall
- Enable authentication (Basic Auth) and enter the credentials in the Drupal Solr connector
- Run Solr as its own non-root user
Scaling with SolrCloud
For large or high-availability setups, run SolrCloud with ZooKeeper, multiple shards and replicas. Search API Solr includes a SolrCloud connector so Drupal can work with collections instead of single cores.
Monitoring
Watch the Solr admin dashboard for heap usage, query times and cache hit rates, and use tools such as Prometheus or Grafana for long-term trends. Check the Drupal status report and Search API status page for indexing errors.
Common Problems and Fixes
| Problem | Likely cause and fix |
|---|---|
| Server shows “not available” | Solr not running, wrong host, port or core name, or firewall blocking |
| Fields missing or errors on indexing | Config set is outdated. Regenerate and re-upload, then reload the core |
| No results for new content | Item not indexed yet. Run drush search-api:index and check cron |
| Facets show wrong values | Field type should be String or Integer, not Fulltext |
| Search is slow | Too many fields, small Solr heap, or bad commit settings |
| Results show unpublished content | Enable the Content access and Entity status processors |
| Indexing is stuck | Check watchdog and Solr logs for a failing item, then reset the tracker |
Quick Implementation Checklist
- Install Java and Solr, and start it
composer require drupal/search_api_solrand enable the modules- Add the Solr server in Drupal
- Generate the config set, create the Solr core with it
- Create the index, choose fields and processors
- Index content with Drush
- Build the search View
- Add Facets and Autocomplete
- Secure Solr and set up cron
- Monitor, tune and regenerate config after changes
Final Thoughts
Solr turns Drupal search from a slow database feature into a fast, flexible search experience, and it reduces the load on your main database and CPU. Start with the basics, get a working index and search page, then add facets, autocomplete and tuning as your site grows. Always keep the Solr config set in sync with your Drupal index, secure the server, and run indexing from cron or Drush.
Need help setting up Solr search on your Drupal project? Get in touch and we can plan the right setup for your site.
