Use Elasticsearch with Drupal

Elasticsearch rocks. But can I use it with Drupal?
Spoiler alert: Yes fully supports both Elasticsearch and Solr
Apache Solr

Add three lines to services.yaml


    type: elasticsearch:6.5

    disk: 512

Add one line to


    elasticsearch: 'elasticsearch:elasticsearch'

Install Drupal modules

composer require drupal/elasticsearch_connector drupal/search_api

Configure a Cluster in Drupal

Create a cluster and note the machine name

Note the machine name you give it

Drop some glue code into settings.php

// Update these values to the relationship name (from

// and the machine name of the server from your Drupal configuration.

$relationship_name = 'elasticsearch';

$es_server_name = 'my_cluster';

if ($platformsh->hasRelationship($relationship_name)) {

  $platformsh->registerFormatter('drupal-elastic', function($creds) {

    return sprintf('http://%s:%s', $creds['host'], $creds['port']);


$config['elasticsearch_connector.cluster.' . $es_server_name]['url'] =

    $platformsh->formattedCredentials($relationship_name, 'drupal-elastic');