Skip to main content

Search API Solr Overrides

Maintaining multiple Drupal 7 environments with unique configuration is hard. Maintaining different Solr configuration for these environments is even harder. Enter Search API Solr Overrides; the easier approach.

by nick.schuch /

On the past few projects at PreviousNext we have had a requirement to have a separate Solr configuration for each of our environments. However, we have always found the problem of keeping these separate configurations in the one code base. Some solutions that would solve this problem are:

  • Manually edit each environments’ configuration. The is very painful approach, what if you missing something?
  • Keep a separate configuration (generally a feature export) per environment. While this is a step in the right direction its still painful to maintain all those code bases.
  • Setup a generic configuration with the host ‘solr’ and update local DNS entries to the appropriate host. This is a very advanced answer to the question and requires expert knowledge when debugging issues.
  • Take advantage of search_api hooks to set the configuration. This is where Search API Solr Overrides comes in.

With the power of settings.php (file not maintained in repository) defined variables and the hook hook_search_api_server_load() provided by search_api we have made a simple contrib module that allows for environment based configuration. Once your site has search_api_solr_overrides installed you can go ahead and update your settings.php using the following example.

$conf['search_api_solr_overrides'] = array(
  '' => array(
    'name' => t('Solr Server (Overridden)'),
    'options' => array(
      'host' => '',
      'port' => '',
      'path' => '',


Module page -

Posted by nick.schuch
Sys Ops Lead



Comment by Chris Pliakas


This is what the Apache Solr Search Integration module has been doing for years with great success, so I am glad this technique is being resurrected for Search API.

Keeping a separate configuration per environment is not a viable solution due to the major issue at If you have multiple environments that are disabled, the tasks build up in the variables table and are never cleaned automatically eventually causing your site to crash because it grows so large. Just a word of caution to those reading this post as I have seen a lot of sites take this approach and fail as a result.

Thanks for posting this module.

Comment by Murray


Thanks Nick. Very helpful.