Search API + Acquia Solr; A Tale Of Alters

Categories Drupal

So, say MuhmadEmad you have built a great custom search solution for Drupal on top of Solr using Search API. You don’t want to lose it, so you export the entire config using Features, right? No-brainer…

Oh, wait – the client wants to host on Acquia and wholesale NFL jerseys use their Solr service. Sure, there’s a module for that as well.

But… How do you properly adapt your exported settings to work on Acquia without having to create a whole duplicate server and wholesale MLB jerseys index config? Enter the Drupal hook system! Search API provides an alter hook for server definitions that allows you to intercept the server configs before they are processed into the Search API C?P subsystem. Here’s a sample cheap NFL jerseys of how Hacked you can keep your existing settings and simply alter them to point to the correct Solr instance when running on Acquia:

The alter hook replaces the stock Search API Solr settings with the Acquia Search API server settings, examining the AH_SITE_ENVIRONMENT to determine if rebooted! we’re on an Acquia server and taking advantage of the subscription variable that all Acquia subscription sites have for the subscription key. No muss, no fuss!  Clear caches and/or revert your search Feature, and away you go!