Setup Drupal 8 Acquia Search on Acquia Cloud Site Factory

Vipin Mittal
3 min readMar 9, 2020

Drupal 8 Acquia search provides a blazing full text search experience to the end users.

To set up the Acquia search on Acquia Cloud Site Factory (ACSF), follow the below steps sequentially:

  1. Add the following code at \factory-hooks\post-settings-php\includes.php.
<?php/*** @file* Example implementation of ACSF post-settings-php hook.** @see https://docs.acquia.com/site-factory/tiers/paas/workflow/hooks*/// Set config directories to default location.$config_directories['vcs'] = '../config/default';$config_directories['sync'] = '../config/default';$config['search_api_solr.settings']['site_hash'] = $GLOBALS['gardens_site_settings']['conf']['acsf_db_name'];if (isset($_ENV['AH_SITE_ENVIRONMENT'])) {  if ($_ENV['AH_SITE_ENVIRONMENT'] == 'dev') {    $config['acquia_search.settings']['connection_override'] = [    'scheme' => 'https',    'port' => 443,    'host' => 'zone.acquia-search.com',    'index_id' => 'XXXX-XXXXXX.dev.default',    'derived_key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',    ];  }  elseif ($_ENV['AH_SITE_ENVIRONMENT'] == 'test') {    $config['acquia_search.settings']['connection_override'] = [    'scheme' => 'https',    'port' => 443,    'host' => 'zone.acquia-search.com',    'index_id' => 'XXXX-XXXXXX.test.default',    'derived_key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',    ];  }  elseif ($_ENV['AH_SITE_ENVIRONMENT'] == 'live') {    $config['acquia_search.settings']['connection_override'] = [    'scheme' => 'https',    'port' => 443,    'host' => 'zone.acquia-search.com',    'index_id' => 'XXXX-XXXXXX',    'derived_key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',    ];  }}

Note: host, index_id & derived_key will get by raising the support ticket in Acquia. Acquia team will provide the key values only. Refer below screengrab

PHP Code for Acquia Search Settings

2. Download the following modules:

Install the downloaded modules along with Acquia Search module. Refer below screengrab:

Modules Admin Interface

3. Set up Acquia connector settings at <domain.com>/admin/config/system/acquia-connector. Refer below screengrab:

Acquia Connector Configuration Admin Interface

4. Configure the Search API for the functioning of Acquia search. This includes two major steps

  • Add search Server
  • Setup Search Index
Search API

5. Add Search Server

  • Go to configuration > Search API and click on “+ Add server”
  • Input Server name as per your choice
  • Select Acquia Solr Connector, please ignore the error which will prompt on the screen.
  • Click on “Save” button.
    Refer below screengrab:
Solr Server Admin Interface

6. Configure Search Index

  • Go to configuration > Search API and click on “+ Add index”
  • Add Search Index name
  • Select “content” Datasources.
  • Select “Acquia Search API Solr server” Server from the options.
  • Click on “Save and add fields”
    Refer below screengrab:
Solr Search Index entity Admin Interface
  • Now add fields that would like to cover in search results. Refer below screengrab:
Solr Index Fields Admin Interface
  • Select the processors that would like to enable and click “Save” button. Refer below screengrab:
Solr Index Processors Admin Interface

After Setting up Server and index, following screen will appear with the right tick sign.

Search API Dashboard

7. Indexed content

  • Go to Configuration > Search API > Acquia Solr Search index.
  • Click on “Index now” button.
    Refer below screengrab:
Indexed Content Admin Interface

8. Search result view page

  • Go to Structure > Views > Acquia Search
    This is default view page for search result
Acquia Search View

Congratulations! You have just configured the Acquia search successfully.

Any feedback is welcome and appreciated!!

--

--

Vipin Mittal

He is Passionate coder and Drupal enthusiast with 15 years core Drupal experience. He is Acquia Drupal certified and involved in different upgrades/migrations.