This article is a detailed guide to enabling Elasticsearch on Magento Commerce Cloud.
Step 1: Activate on Integration; request on Staging and Production
1.1: Activate on Integration environment
Make changes in .magento/services.yaml and .magento.app.yaml configuration files on your local development environment. Then, git push the changed files to your Integration environment to enable Elasticsearch there.
This step is covered on DevDocs, see Add Elasticsearch in services.yaml and .magento.app.yaml.
Add the Elasticsearch section:
elasticsearch: type: elasticsearch:5.2 disk: 1024
type includes the version to be installed and
disk specifies the allocated disc space (in MB).
relationships section, add the elasticsearch line:
If you used the Solr search before, delete the Solr line to avoid memory leaks:
After changes, the
relationships section might look like this:
relationships: database: "mysql:mysql" redis: "redis:redis" elasticsearch: "elasticsearch:elasticsearch"
1.2: Request activation on Staging and Production
Submit a support ticket requesting to activate Elasticsearch on your Staging and Production environments.
In your ticket, please specify the Elasticsearch version you want to activate. Following are the supported and preferred versions:
- Magento 2.1.0 - 2.1.2 supports ES 1.7 / 2.4 (2.4 preferred)
- Magento 2.2.3 - 2.3.0 supports ES 1.7 / 2.4 / 5.2 (5.2 preferred)
- Magento 2.3.0+ supports ES 5.2
Step 2: Push changes to Integration
To enable Elasticsearch on the Integration environment, add the changed YAML files to git and push changes to the server:
git add -A git commit -m "Switching solr for elaticsearch" git push <name_of_remote_repo> <name_of_remote_branch>
For Staging and Production, pushing the changed YAML files does not trigger the activation. Elasticsearch is only enabled once your support ticket (the one that requests the activation) is processed.
Step 3: Configure Magento to use Elasticsearch
You must perform this step for any environment (Integration, Staging, Production) to get Elasticsearch working.
For Staging and Production environments, this configuration step is only available after your support ticket for activating Elasticsearch has been processed successfully and Elasticsearch has been activated.
For Magento Commerce Cloud 2.2.0 (and later) with the Configuration Management functionality, the Elasticsearch configuration settings (applied on the Integration environment) are stored and applied automatically once you trigger the deployment procedure on Staging and Production environments. So all you need to do is running Catalog Search full reindex. See detailed steps in the following section.
Run Catalog Search full reindex
- To build fresh indexes for the newly installed Elasticseach instance, run the Catalog Search full reindex using the following command:
bin/magento indexer:reindex catalogsearch_fulltext
- Clean cache by running
bin/magento cache:cleanor in Magento Admin under System > Tools > Cache Management.