Set up OpenSearch service
CREATED FOR:
- Admin
- Developer
The OpenSearch service is an open-source fork of Elasticsearch 7.10.2, following the licensing changes for Elasticsearch. See the OpenSource Project in GitHub.
OpenSearch enables you to take data from any source, any format, and search and visualize it in real time.
- Quick and advanced searches on products in the product catalog
- OpenSearch Analyzers support multiple languages
- Supports stop words and synonyms
- Indexing does not impact customers until the reindex operation completes
Use the following instructions for service setup on Pro Integration environments and Starter environments, including the master
branch.
To enable OpenSearch:
-
For Starter and Pro integration environments, add the
opensearch
service to the.magento/services.yaml
file with the appropriate version and allocated disk space in MB. In this case, version 2 is appropriate. The minor version is not required because cloud infrastructure uses the latest version of OpenSearch.opensearch: type: opensearch:2 disk: 1024
For Pro projects, you must Submit an Adobe Commerce Support ticket to change the OpenSearch version in the Staging and Production environments.
-
Set or verify the
relationships
property in the.magento.app.yaml
file.relationships: opensearch: "opensearch:opensearch"
-
Add, commit, and push code changes.
git add .magento/services.yaml .magento.app.yaml
git commit -m "Enable OpenSearch"
git push origin <branch-name>
For information on how these changes affect your environments, see Configure services.
-
After the deployment process completes, use SSH to log in to the remote environment.
magento-cloud ssh
-
Reindex the Catalog Search index.
bin/magento indexer:reindex catalogsearch_fulltext
-
Clean the cache.
bin/magento cache:clean
services.yaml
and .magento.app.yaml
configuration files. See Change service version for guidance on upgrading or downgrading a service.OpenSearch software compatibility
When you install or upgrade your Adobe Commerce on cloud infrastructure project, always check for compatibility between the OpenSearch service version and the OpenSearch PHP client for Adobe Commerce.
-
First time setup–Confirm that the OpenSearch version specified in the
services.yaml
file is compatible with the OpenSearch PHP client configured for Adobe Commerce. -
Project upgrade–Verify that the OpenSearch PHP client in the new application version is compatible with the OpenSearch service version installed on the cloud infrastructure.
Service version and compatibility support is determined by versions tested and deployed on the Cloud infrastructure, and sometimes differ from versions supported by Adobe Commerce on-premises deployments. See System requirements in the Installation Guide for a list of supported versions.
To verify OpenSearch software compatibility:
-
On your local workstation, change to your project directory.
-
Show the OpenSearch details for the active environment.
magento-cloud relationships --property=opensearch
-
Alternatively, you can use SSH to log in to the remote environment.
magento-cloud ssh
-
Retrieve the OpenSearch service connection details.
vendor/bin/ece-tools env:config:show services
In the response, find the IP address and port for the OpenSearch service endpoint:
+------------------------------------------+--------------------------------------------------------+ | opensearch: | +------------------------------------------+--------------------------------------------------------+ | username | null | | scheme | http | | service | opensearch | | fragment | null | | ip | 169.254.220.11 | | hostname | hostf75wi3sd24l.opensearch.service._.magentosite.cloud | | port | 9200 | | cluster | projectID-develop-4ranwui | | host | opensearch.internal | | rel | opensearch | | path | null | | query | | | password | null | | type | opensearch:2 | | public | false | | host_mapped | false |
-
Retrieve the installed OpenSearch service
version:number
from the service endpoint.curl -XGET <opensearch-service-endpoint-ip-address>:9200
{ "name" : "opensearch.0", "cluster_name" : "opensearch", "cluster_uuid" : "_yzaae6-ywSEW1MaAF8ZPWyQ", "version" : { "distribution" : "opensearch", "number" : "2.5.0", "build_type" : "deb", "build_hash" : "aaaaaaa", "build_date" : "2023-01-23T12:07:18.760675Z", "build_snapshot" : false, "lucene_version" : "9.4.2", "minimum_wire_compatibility_version" : "7.10.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "The OpenSearch Project: https://opensearch.org/" }
Staging
and Production
environments only..magento.app.yaml
and services.yaml
files, and state the PHP version in the ticket. For self-service changes to PHP version, extensions, or environment settings, see PHP settings in Application configuration.Restart the OpenSearch service
If you need to restart the OpenSearch service, you must contact Adobe Commerce support.
Additional search configuration
-
By default, the search configuration for Cloud environments regenerates each time you deploy. You can use the
SEARCH_CONFIGURATION
deploy variable to retain custom search settings between deployments. See Deploy variables. -
After you set up the OpenSearch service for your project, use the Admin UI to test the OpenSearch connection and customize OpenSearch settings for Adobe Commerce.
Add plugins for OpenSearch
Optionally, you can add plugins for OpenSearch by adding the configuration:plugins
section to the OpenSearch service in the .magento/services.yaml
file. For example, the following code enables the ICU analysis and Phonetic analysis plugins.
opensearch:
type: opensearch:2
disk: 1024
configuration:
plugins:
- analysis-icu
- analysis-phonetic
See the OpenSearch Project for more information on plugins.
Remove plugins for OpenSearch
Removing the plugin entries from the opensearch:
section of the .magento/services.yaml
file does not uninstall or disable the service. To fully disable the service, you must reindex your OpenSearch data after removing the plugins from your .magento/services.yaml
file. This design prevents the possible loss or corruption of data that depends on these plugins.
To remove OpenSearch plugins:
-
Remove the OpenSearch plugin entries from your
.magento/services.yaml
file. -
Add, commit, and push your code changes.
git add .magento/services.yaml
git commit -m "Remove OpenSearch plugin"
git push origin <branch-name>
-
Commit the
.magento/services.yaml
changes to your cloud repository. -
Reindex the Catalog Search index.
bin/magento indexer:reindex catalogsearch_fulltext
-
Clean the cache.
bin/magento cache:clean