Skip to content

MeceInstall

Romain Ruaud edited this page Apr 7, 2022 · 10 revisions

Installing ElasticSuite on Magento Enterprise Cloud Edition

If you are using Magento Enterprise Cloud Edition, you may wonder how you'll be able to use ElasticSuite on such an environment.

We already dug into this specific installation process and can tell you this is working perfectly.

Here are the steps to follow in order to get a running instance of ElasticSuite.

Configure ElasticSearch service and the required plugins

First step is to enable Elasticsearch service on the cloud instance.

To do this, you have to edit the services.yaml file of your project according to this sample :

# The services of the project.
#
# Each service listed will be deployed to power your project.

mysql:
    type: mysql:10.0
    disk: 2048

redis:
    type: redis:3.0

elasticsearch:
    type: elasticsearch:2.4
    disk: 1024
    configuration:
        plugins:
            - analysis-icu
            - analysis-phonetic


The "disk" parameter may vary according the size of your index. 1024 (1Go) is just a "basic" value and could be increased according to your total number of products.

Declare the Elasticsearch service

The next step is to edit the .magento.app.yaml file and to declare the Elasticsearch services into the relationships node :

relationships:
    database: "mysql:mysql"
    redis: "redis:redis"
    elasticsearch: "elasticsearch:elasticsearch"

Only the elasticsearch line is relevant

Ensure proper Elasticsearch configuration is set for inline scripts

You have to ensure that the inline script feature of Elasticsearch is enabled. You can ask the Magento Cloud team to add the following lines in the Elasticsearch configuration :

script.allowed_types: inline
script.allowed_contexts: search,update,aggs

Ensure Magento is using ElasticSuite

To be sure that Magento will use ElasticSuite as Search Engine, you will have to enforce the engine by setting the SEARCH_CONFIGURATION variable.

You can do this with the following command-line :

magento-cloud project:variable:set --json SEARCH_CONFIGURATION '{"engine":"elasticsuite"}'

Ensure proper configuration for ElasticSuite host

By using an environment variable.

Since the ElasticSearch server is basically named elasticsearch.internal on MECE, you will have to handle this specific configuration.

You can achieve this by specifying the following environment variable to all environment by adding it to your .magento.app.yaml file like this :

variables:
  env:
    CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__SERVERS: 'elasticsearch.internal'

Deprecated solution : by using a module embedding the configuration.

If you did choose to use an environment variable, you can ignore this step.

You can create a new module to embed the configuration.

This module will only contain two files :

etc/module.xml :

<?xml version="1.0" ?>
<config
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="MyVendorName_ElasticSuite" setup_version="0.0.1">
        <sequence>
            <module name="Smile_ElasticsuiteCore"/>
        </sequence>
    </module>
</config>

etc/config.xml :

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <smile_elasticsuite_core_base_settings>
            <es_client>
                <servers>elasticsearch.internal:9200</servers>
            </es_client>
        </smile_elasticsuite_core_base_settings>
    </default>
</config>

Ensure proper configuration for ElasticSuite indexes alias

⚠️ According to Magento official documentation the staging and production platform are using a shared and single Elasticsearch instance.

This means that you will have to ensure your Elasticsearch indexes have different names between the staging and the production environment.

Hopefully, this can be easily achieved either :

  • in the module configuration via the Indices alias name parameter. This will require manually editing this configuration scope.

  • on a technical way, by specifying a different value between staging and production the following environment variable (not a "Project variable" but an "Environment variable")

env:CONFIG__DEFAULT__SMILE_ELASTICSUITE_CORE_BASE_SETTINGS__ES_CLIENT__INDICES_ALIAS

Please note the "env:" pattern before the variable name as stated in the Magento documentation

Please ensure you are using a different alias name between your staging and production environment.

E.g : 'myproject_stg' and 'myproject_prod' should fit your needs and keep you safe from index collisions.

Deliver your environment

If you did all the step before in a dedicated branch, the environment for this branch should work properly once it has been delivered and deployed into the Cloud.

Once you will have done all this, you should be all set.

Clone this wiki locally