Set up Elasticsearch

Elasticsearch is an open source product that enables you to take data from any source, any format, and search, and visualize it in real time.

  • Elasticsearch performs quick and advanced searches on products in the product catalog
  • Elasticsearch analyzers support multiple languages
  • Supports stop words and synonyms
  • Indexing does not impact customers until reindex is completed

We support Elasticsearch versions 1.4, 1.7, and 2.4. The default version is 1.7.

This feature is supported in Magento 2.1 only We support Elasticsearch for all environments starting with Magento Commerce (Cloud) 2.1 and later.

We recommend installing and configuring Elasticsearch in all of your environments: Integration, Staging, and Production. All configuration settings should be in the following files in your branch then deployed. The following sections provide configuration information and supported plugins.

For full documentation to install and configure Elasticsearch per web server, see Elasticsearch information.

If you’re upgrading to Magento Commerce 2.1.3, you must change your configuration as discussed in the 2.1.3 Release Notes.


We use the Magento Commerce (Cloud) environment variable $MAGENTO_CLOUD_RELATIONSHIPS, a JSON object, to retrieve environment-related relationships.

The following is the Elasticsearch information:

"elasticsearch" : [
         "host" : "elasticsearch.internal",
         "ip" : "",
         "scheme" : "http",
         "port" : "9200"

Configure service settings

Configure the Elasticsearch version and additional values in .magento/services.yaml. The following example is the default version setting for Elasticsearch.

   type: elasticsearch:1.7
   disk: 1024

To configure the relationships for environment variable, set a relationship in your in the Git branch. For example:

    elasticsearch: "elasticsearch:elasticsearch"

Merge and deploy the code to set the configurations for Elasticsearch.

Add Elasticsearch to your site

Add the service in a configuration file of your application. For example:

  $relationships = json_decode(base64_decode($_ENV['MAGENTO_CLOUD_RELATIONSHIPS']), TRUE);

  foreach ($relationships['elasticsearch'] as $endpoint) {
    $container->setParameter('elasticsearch_host', $endpoint['host']);
    $container->setParameter('elasticsearch_port', $endpoint['port']);

When you create an index on Elasticsearch, you should not specify number_of_shards and number_of_replicas settings in your Elasticsearch API call. These values will be set automatically based on available resources.

Supported plugins

The following are supported Elasticsearch plugins for version 2.4:

  • analysis-icu: ICU Analysis Plugin, Support ICU Unicode text analysis
  • analysis-kuromoji: Japanese (kuromoji) Analysis Plugin, Japanese language support
  • analysis-phonetic: Phonetic Analysis Plugin, Phonetic analysis
  • analysis-smartcn: Smart Chinese Analysis Plugins
  • analysis-stempel: Stempel Polish Analysis Plugin
  • cloud-aws: AWS Cloud Plugin, allows storing indices on AWS S3
  • cloud-azure: Azure Cloud Plugin
  • cloud-gce: GCE Cloud Plugin
  • delete-by-query: Support for deleting documents matching a given query
  • discovery-multicast: Ability to form a cluster using TCP/IP multicast messages
  • lang-javascript: Javascript language plugin, allows the use of Javascript in Elasticsearch scripts
  • lang-python: Python language plugin, allows the use of Python in Elasticsearch scripts
  • mapper-attachments: Mapper attachments plugin for indexing common file types
  • mapper-murmur3: Murmur3 mapper plugin for computing hashes at index-time
  • mapper-size: Size mapper plugin, enables the _size meta field

For full documentation on these plugins, see Elasticsearch plugin documentation.

You can add the plugins through the .magento/services.yaml file using the codes above. For example, to enable ICU analysis plugin and Python script support plugins, add the configuration plugins section with the listed plugin codes:

   type: elasticsearch:1.7
   disk: 1024
      - analysis-icu
      - lang-python