Nick SchuchOperations Lead
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.
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' => '', ), ), );
Resources
Module page - http://drupal.org/project/search_api_solr_overrides