How To Configure Magento 2 OpenSearch on Cloud in 6 Steps
Vinh Jacker | 11-11-2024
Are you feeling limited by the search functionality of your Magento store? Magento OpenSearch is here to help. By harnessing the power of Elasticsearch, it provides a superior search experience with fast, precise results, boosting user satisfaction and engagement.
In this tutorial, we’ll show you how to set up Magento OpenSearch services. Follow along as we guide you through the process of integrating this powerful search tool with your Magento store.
Introduction to OpenSearch in Magento 2
Magento OpenSearch is a free, open-source search tool built on Elasticsearch.
OpenSearch serves a variety of functions, from powering search engines to conducting data analysis. It originated as a fork of Elasticsearch 7.10.2 and Kibana 7.10.2, responding to significant licensing changes by Elasticsearch that raised concerns in the open-source community about the future availability and openness of Elasticsearch and Kibana. OpenSearch emerged as a community-driven alternative, ensuring ongoing access to:
- Open-source tools
- Free search capabilities
- Analytics suites
Its core features support the seamless storage, search, and analysis of large datasets in near real-time, making it ideal for applications requiring detailed text-heavy or complex data structure searches.
The popularity of OpenSearch is due to its effectiveness in meeting diverse needs. It has become the preferred solution for various implementations, including website and logging system searches. Its versatility and powerful capabilities make it an invaluable tool for organizations seeking robust search solutions.
Benefits of Using OpenSearch
There are numerous advantages to using OpenSearch as a search and analysis suite. Here are some key benefits:
-
Open Code: OpenSearch adheres fully to open-source principles, allowing the code to be freely used, adapted, and commercialized. The software can be downloaded, installed, and operated at no cost.
-
Programming Languages: OpenSearch supports several programming languages, including Python, Java, JavaScript, Go, Ruby, PHP, .NET, and Rust. Most language clients compatible with Elasticsearch 7.10.2 are also supported. OpenSearch provides detailed information about this on their language clients overview page.
-
Distributed Architecture: With its distributed infrastructure, OpenSearch can aggregate and store large amounts of data in real-time. Its flexible scalability enables quick responses to peak loads.
-
Visualization and Reporting: OpenSearch dashboards allow for real-time monitoring and analysis of data. Data can be visualized graphically and exported into reports.
-
Persistent Data Storage: Data is stored in JSON format, making it reusable by any tool with a JSON-enabled API.
Migrating to OpenSearch from Elasticsearch
To migrate from Elasticsearch to OpenSearch for Adobe Commerce on Cloud or Magento Open Source, including version 2.4.6, follow these integrated steps:
Step 1: Backup Elasticsearch
- Utilize GitHub for scripting data snapshots.
- Include the catalog search index in these snapshots.
Step 2: Setting Up OpenSearch
- Set up an OpenSearch cluster.
- Ensure compatibility with Elasticsearch 7 or 7.10.2.
- Match settings such as
cluster_name
,build_hash
, andlucene_version
with requirements.
Step 3: Data Migration
- Use snapshots and restore or reindex for data transfer.
- Adjust
minimum_wire_compatibility_version
andminimum_index_compatibility_version
settings accordingly.
Step 4: Updating Configuration
You can switch from Elasticsearch to OpenSearch for configuration updates in Adobe Commerce, ensuring that the hostname and build_snapshot
settings are configured for OpenSearch.
Step 5: Verification
Verify migration by checking:
- Catalog search index
- Compatibility
- Performance
Conduct verification in various environments, including Docker, AWS, and on-premises setups.
Step 6: Monitoring and Support
After completing the migration, utilize OpenSearch Dashboards for monitoring. In case of any issues, reach out to Adobe Commerce or Magento Open Source support teams for assistance.
Ensure all installations, whether on cloud, on-premises, or Adobe Commerce Cloud, are updated.
It’s important to continue supporting Elasticsearch until the transition to OpenSearch is finalized.
Note that Elasticsearch versions newer than 7.10 are incompatible with Adobe Commerce on Cloud Infrastructure version 2.4.4. Upgrade to Adobe Commerce 2.4.4 and transition to OpenSearch version 1.2.x, as Elasticsearch 7 and OpenSearch 1.2 are compatible.
For new installations, OpenSearch is the default choice for Adobe Commerce Cloud, offering enhanced search capabilities through OpenSearch and OpenSearch Dashboards.
Configuring OpenSearch Service in Adobe Commerce on Cloud
Step 1: Adding OpenSearch Service to Your Project
Navigate to your .magento/services.yaml
file and add the OpenSearch service with the desired version and disk space allocation.
services:
opensearch:
type: opensearch:2.0
disk: 2048
Ensure to adjust the disk space (disk)
as per your requirements.
Step 2: Configuring Relationships for OpenSearch
In your .magento/services.yaml
file, configure the relationships to include the OpenSearch service. In this phase, the newly introduced OpenSearch service is connected to your application.
For example:
relationships:
opensearch: "opensearch:opensearch"
Step 3: Deploying Your Changes
Commit your changes to Git:
git commit -am "Add OpenSearch service"
Push your changes to trigger deployment:
git push
Step 4: Accessing Your Magento Environment
After deployment, access your Magento environment using the Magento Cloud CLI or the Project Web Interface.
Step 5: Reindexing Catalog Search
To reindex the Catalog Search index with OpenSearch, run the Magento indexer command:
bin/magento indexer:reindex catalogsearch_fulltext
Step 6: Clearing Cache
To guarantee that the changes take effect right away, clear the Magento cache:
bin/magento cache:clean
FAQs
What is Magento Opensearch, and how does it relate to Elasticsearch?
Magento Opensearch is an advanced search technology designed for Magento 2, offering a more secure and scalable alternative to Elasticsearch.
Can Elasticsearch still be used with Magento Open Source?
Yes, Elasticsearch remains compatible with Magento Open Source. However, transitioning to Opensearch is recommended for improved performance and enhanced security.
How do I reindex the catalog search after migrating to Opensearch?
Following migration to Opensearch, reindexing the catalog search involves executing specified commands provided in Magento’s documentation. This ensures all product data is properly indexed for search queries.
Is Magento Opensearch supported for Adobe Commerce on Cloud infrastructure?
Yes, Adobe Commerce on Cloud infrastructure fully supports Magento Opensearch, enabling enhanced search capabilities for Adobe Commerce websites.
Can I switch from Elasticsearch to Opensearch on on-premises installations?
Yes, transitioning from Elasticsearch to Opensearch on on-premises installations is possible. Ensure a smooth transition by following Magento’s provided migration guide.
Does Magento 2.4.6 support both Elasticsearch and Opensearch?
Yes, Magento 2.4.6 supports both Elasticsearch and Opensearch, allowing users to choose the search engine that best fits their specific requirements.
Conclusion
In short, Magento OpenSearch, a free and open-source search tool based on Elasticsearch, significantly enhances search functionality by providing swift and accurate results. This article covered the comprehensive process of setting up OpenSearch, ensuring its compatibility with Magento, and verifying its seamless operation. We also provided a detailed guide on the setup and integration of Magento OpenSearch, highlighting its seamless integration with Adobe Commerce on the Cloud.
By following these best practices, you can leverage Magento OpenSearch to deliver an improved user experience and drive your eCommerce business towards greater success.