OpenSearch and Magento

Long gone the days where Magento could work with just the search powered by mysql. Using mysql was convenient when using a development environment.

We had to come to terms with this change and using elasticsearch was the new method to deploy a Magento environment.

In this article, we describe the latest hurdle that Magento installation has added: that is using opensearch with Magento 2.4.6 and above

I have explored 2 different solutions today and I will describe both.

Installing OpenSearch locally on Ubuntu environment

The place that I have tried to use was https://opensearch.org/docs/latest/install-and-configure/install-opensearch/debian/

The install went ok until the end when I encountered the error that OPENSEARCH_INITIAL_ADMIN_PASSWORD needed to be setup. Whilst many places describe solutions for this issue, it turned out to be fruitless. The article https://medium.com/@doriankno/setting-up-and-testing-opensearch-on-ubuntu-22-04-5fb481786466 was hopeful and in fact did bring good results. However, at this point, it was becoming very convoluted with ubuntu dependencies issues and the config setting not working.

Fortunately, I had docker installed already and it came as a possibility to delegate to a self-contained solution using docker was a likely simpler solution.

Installing OpenSearch locally with docker

docker pull opensearchproject/opensearch:2
docker pull opensearchproject/opensearch-dashboards:2
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=yourStrongPassword123!" opensearchproject/opensearch:latest
curl https://localhost:9200 -ku 'admin:yourStrongPassword123!'

This snippet above went through quite quickly.

reference: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/

Set the permissions

https://askubuntu.com/questions/386928/default-permissions-for-var-www

Add sample data

composer require magento/module-bundle-sample-data magento/module-widget-sample-data magento/module-theme-sample-data magento/module-catalog-sample-data magento/module-customer-sample-data magento/module-cms-sample-data  magento/module-catalog-rule-sample-data magento/module-sales-rule-sample-data magento/module-review-sample-data magento/module-tax-sample-data magento/module-sales-sample-data magento/module-grouped-product-sample-data magento/module-downloadable-sample-data magento/module-msrp-sample-data magento/module-configurable-sample-data magento/module-product-links-sample-data magento/module-wishlist-sample-data magento/module-swatches-sample-data magento/sample-data-media magento/module-offline-shipping-sample-data --no-update
composer update
bin/magento sampledata:deploy

bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData

https://stackoverflow.com/questions/32668486/how-do-i-install-the-sample-data-after-setting-up-magento2

bin/magento mod:dis Magento_TwoFactorAuth Magento_AdminAdobeImsTwoFactorAuth