lcatlett
11/3/2017 - 3:44 PM

Acquia Search Setup - BLT / DrupalVM etc

Acquia Search Setup - BLT / DrupalVM etc

Acquia Search Setup

This guide is intended to help you get everything setup on a new site so that you can use Acquia Search across your local development environments, as well as in the Acquia Cloud (without having to worry about your environments cross-contaminating its SOLR indexes with the wrong data).

The end result will be configuration that is different in each of your environments (local/dev/stage/prod) yet still functional across each.

Step 1: Acquia Cloud

Put in a support ticket on your Acquia Cloud subscription to have Acquia Search enabled for your site. The support engineers will ensure your subscription includes Acquia Search, and then setup the necessary servers for your environments.

##Step 2: Drupal Modules

Confirm you have all required modules locally:

  • Config Split
  • Search API
  • Search API SOLR
  • Acquia Connector
  • Acquia Search

Note that by default all of the above are included with BLT other than Search API SOLR. Add missing modules to your composer.json and run composer update.

Make sure you consult the https://docs.acquia.com/acquia-search/modules documentation to review the supported versions of Acquia Connector, Search API, and Search API Solr, as not all combinations are supported.

Step 3: Drupal VM

Make sure your Drupal VM is configured to handle SOLR. It most likely is not, since the default BLT configuration does NOT include SOLR.

Open your box config.yml file and make the following changes!

  • Add solr in the list of installed extras
installed_extras:
  - adminer
  - drush
  - mailhog
  - nodejs
  - selenium
  - solr
  - xdebug
post_provision_scripts:
- "../../../acquia/blt/scripts/drupal-vm/post-provision.sh"
- "../../../acquia/blt/scripts/drupal-vm/solr-provision.sh"
```

solr_version: "4.5.1"



* Reprovision your VM to add SOLR 

$ vagrant reload -- provision


* Visit the solr dashboard to ensure it installed correctly @ http://local.project.com:8983/solr/#/

## Step 4: Setup Configuration Splits

Ensure that your local is setup to support BLTs configuration splits. See the BLT documentation for assistance with this -- http://blt.readthedocs.io/en/latest/readme/config-split/

## Step 5: Setup Search Configuration

The end goal of this step is to have a Search Index (this will be created automatically by Acquia Search when installed) that can be "passed" between different servers based on the environment that you are currently in.

This is most easily accomplished by: 
1. Enable Acquia Connector locally
2. Once authenticated, enable Acquia Search
3. Create a local SOLR server ex: https://gist.github.com/lcatlett/66a227639dd3fdaeb727d6994dd917ae
3. Plac3 the Local server configuration in the config/local directory
4. Placing a copy of the Acquia Search Index in the local directory and changing the server to be "local" instead of the default Acquia Search Server. This is typically on the last line. 

server: local


## Step 6: Customize Configuration for Dev/Test/Prod

The Acquia Connector will automatically facilitate the search configuration based on the Acquia environment. From here, all you need to do is export the configuration for each environment and place it in the appropriate config split folders.



## Wrap Up

Once properly configured, local development can occur using the same index that all environments will use. However, due to the configuration changing servers, the index will always live on the appropriate server in the appropriate environment. 

## Local Development 
To develop with search on your local index, you should put the following in local.settings.php:

$config['acquia_search.settings.disable_auto_switch']= TRUE; $config['acquia_search.settings.disable_auto_read_only']= TRUE;


This will override the default read-only behavior of the local index. Take caution that you do not contaminate one of the upstream search cores!