MySQL catalog search engine will be removed in Magento 2.4.0. You must have Elasticsearch host setup and configured prior to installing version 2.4.0. Refer to Install and configure Elasticsearch.
This article provides a solution for changing the Magento Search Engine using the Magento Admin if the Search Engine field is not displayed or the Use system value checkbox is greyed out and not accessible.
In this article:
- Affected versions
- Change Search Engine using Magento Admin (steps)
- Issues with Magento Commerce (On-Premise)
- Magento Commerce (Cloud)
Affected versions
- Magento Commerce (On-Premise): 2.X.X
- Magento Commerce (Cloud):
- Version: 2.X.X
- Plan: Starter, Pro
- MySQL, Elasticsearch: all supported versions
Change Search Engine using Magento Admin (steps)
- Log in to Magento Admin as an Administrator.
- On the left-side Admin sidebar, click Stores. Then, under Settings, choose Configuration.
- In the panel on the left under Catalog, choose Catalog.
- Expand the Catalog Search section.
- Go to the Search Engine field and remove selection from the Use system value checkbox.
- Click the Search Engine menu and select one of the available options.
- Click Save Config in the top-right corner of the page.
Issues with Magento Commerce (On-Premise)
Issue 1: Search Engine field is not displayed
When you access the Catalog Search section, the Search Engine menu is not displayed at all.
Cause: Store View is not Default Config
The Store View for Magento Admin has been set to any value other than Default Config.
The search engine is a global configuration set on the application level, not on the Store Scope. Stores within a Magento application cannot use different search engines.
Solution: Set Store View to Default Config
- Log in to Magento Admin as an Administrator.
- On the left-side Admin sidebar, click Stores. Then, under Settings, choose Configuration.
- In the upper-left corner, click the Store View selector and choose Default Config.
- Click OK in the confirmation dialog to approve store view change.
Related documentation: Changing Scope (Magento User Guide).
Issue 2: Cannot uncheck "Use system value"
When you access the Catalog Search section of Magento Admin, the Use system value checkbox is greyed out so you cannot remove selection from the checkbox to later change the search engine.
Cause
The default search engine has been configured on the application configuration level in the app/etc/env.php
or app/etc/config.php
files and thus cannot be changed using Magento Admin.
Example of the section with default search engine configuration:
'system' =>
array (
'default' =>
array (
'catalog' =>
array (
'search' =>
array (
'engine' => 'mysql',
),
),
),
),
Solution
Remove the section with default search engine configuration from the app/etc/env.php
or the app/etc/config.php
configuration files.
Related documentation on DevDocs
Magento configuration files (Magento Configuration Guide)
Magento Commerce (Cloud)
Switching search engines using Magento Admin is not available in Magento Commerce (Cloud) due to the way the Cloud infrastructure has been organized.
During the deployment process, the Magento Cloud deployment scripts check if Elasticsearch has been declared in the MAGENTO_CLOUD_RELATIONSHIPS
variable. If declared, Elasticsearch is selected as the active search engine and configured automatically; the MySQL search engine becomes inaccessible in Magento Admin. If the Elasticsearch relationship has not been declared, MySQL is set to active, and Elasticsearch becomes inaccessible.
It is not recommended to edit the app/etc/env.php
or the app/etc/config.php
configuration files directly on your Cloud environment, that is why changing these files to make the Elasticsearch engine to be displayed in Magento Admin (the solution we recommend in the previous section) is not applicable for your Cloud project.
Change search engine on Staging and Production environments
Before switching search engine from MySQL to Elasticsearch on your Staging and Production environments, make sure you have previously submitted a support ticket requesting to enable Elasticsearch on the environment and the ticket has been resolved successfully.
To change the search engine used on your Staging and Production environments, change the SEARCH_CONFIGURATION
environment variable in your .magento.env.yaml
file on your local environment, then push changes to the Integration and Staging/Production environments for the changes to take effect.
If you switch from MySQL to Elasticsearch, the SEARCH_CONFIGURATION variable in the resulting .magento.env.yaml
file might look as follows:
stage:
deploy:
SEARCH_CONFIGURATION:
engine: elasticsearch
elasticsearch_server_hostname: hostname
elasticsearch_server_port: '123456'
elasticsearch_index_prefix: magento
elasticsearch_server_timeout: '15'
Related documentation
Knowledge Base
DevDocs
- Set up Elasticsearch service
- Build and deploy (documentation about the
.magento.env.yaml
configuration file) - Deploy variables (SEARCH_CONFIGURATION section)
- Services (documentation about the
.magento/services.yaml
configuration file)