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' => '',
    ),
  ),
);

Resources

Module page - http://drupal.org/project/search_api_solr_overrides

Posted by Nick Schuch
Sys Ops Lead

Dated

Comments

Comment by Chris Pliakas

Dated

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 http://drupal.org/node/1551302. 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

Dated

Thanks Nick. Very helpful.

Pagination

Add new comment

Restricted HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <h5> <h6>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Not sure where to start? Try typing "hello" or "help" if you get stuck.