Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Set up Elasticsearch service

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 the reindex operation completes

We support Elasticsearch versions 1.4, 1.7, and 2.4. The recommended version is 2.4. We support Elasticsearch for all environments starting with Magento Commerce Cloud 2.1 and later. Refer to Elasticsearch information to learn more.

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

If you prefer using an existing search service, like Elasticsearch, instead of relying on Magento Commerce Cloud to create it for you, use the SEARCH_CONFIGURATION environment variable to connect it to your site.

You can use the following instructions for service setup on Magento Commerce Cloud Pro Integration environments and Starter environments, including master branch. You must submit a support ticket to configure the service on Pro Production and Staging environments. See Services.

Add Elasticsearch in services.yaml and .magento.app.yaml

To enable Elasticsearch, add the following code with your installed version and allocated disk space in MB to the .magento/services.yaml file.

1
2
3
elasticsearch:
    type: elasticsearch:2.4
    disk: 1024

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

1
2
relationships:
    elasticsearch: "elasticsearch:elasticsearch"

Merge and deploy the code to set the configurations for Elasticsearch. For information on how these changes affect your environments, see services.yaml.

Add Elasticsearch plugins

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

1
2
3
4
5
6
7
elasticsearch:
    type: elasticsearch:2.4
    disk: 1024
    configuration:
        plugins:
            - analysis-icu
            - lang-python

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 documentation on plugins, see Elasticsearch plugin documentation.

If you use the ElasticSuite third-party plugin, you must update the ece-tools package to version 2002.0.19 or later.

Verify relationships

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

Use this information to complete Elasticsearch configuration in the Admin Panel.

To verify information used for configurations and settings:

  1. Use SSH to log in to the remote environment.

  2. Create pretty-print of all relationships for services and configuration data for that environment.

    1
    
    php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"])));'
    

Configure Elasticsearch for your site

The last step is to configure Elasticsearch for your catalog search options through the Magento Admin. You will need the information from the variable MAGENTO_CLOUD_RELATIONSHIPS. See Configure Magento to use Elasticsearch to complete your Admin configurations.

Staging and Production environments that are in the same cluster share a single Elasticsearch instance, so you must specify a unique Elasticsearch prefix for each of these environments.

Updated