Today we learned about a nice module that can help vendors to get rid of one of the most controversial decisions made by Adobe in the context of Magento 2: the ElasticSearch component. 

But what is ElasticSearch and why do Magento2 shops even need it in the first place? To understand this, we must take a look how Magento has evolved over the course of the last 10 years. First, there were Magento 1. A quite good framework to code in, which was used by thousands of vendors worldwide and held a nice share of the market. However, it grew old and Magento 2 saw the light of the day, but since then, Developers and Agencies weren't quite super happy with it. With the introduction for ElasticSearch, the happiness even got worse, as now businesses were forced to run an excotic tech stack to power their shops.

What is ElasticSearch?


Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

Pros:

  • Scalability: Elasticsearch can scale horizontally by adding more nodes to a cluster, allowing it to handle large amounts of data and queries
  • Real-time search: Elasticsearch is able to search through documents and return results in milliseconds
  • Flexibility: Elasticsearch supports complex search queries and can handle a wide variety of data types
  • Easy to use: Elasticsearch has a simple RESTful API, making it easy for developers to interact with the engine
Cons:

  • Data Loss: Elasticsearch has a tendency to lose data when nodes fail, This could be mitigate with proper backup and restore strategy
  • Resource Intensive: Elasticsearch can be resource-intensive and may require significant hardware resources to handle large data sets
  • Limited support: Elasticsearch may not be suitable for certain types of queries or data structures, so it may not be the best solution for all use cases
Overall, Elasticsearch is a powerful and versatile search engine that can be used to index, search and analyze large amounts of data quickly and easily. However, it is not without its limitations, and care should be taken when using it in production environments.

Is ElasticSearch good for my Magento2 shop?


Yes, it probably is. ElasticSearch offers quite some nice benefits compared to MySQL Legacy search; however most of our clients do not want to blow up their technological stack, as usually, they already have MySQL but not any ElasticSearch service running in their hosting and it can get quite expensive, especially for smaller vendors, to run ElasticSearch. Magento 2.3.5 had still the possibility to serve Search Requests via MySQL.

How can I replace ElasticSearch with MySQL search instead?


The developers from SwissUp have migrated the code from Magento 2.3.5 to Magento 2.4. Just install this module and you will be able to run your Magento 2 shop again without ElasticSearch: click here to go to GitHub

How can I install the MySQL Legacy Search?


This is quite easy. Just follow this steps to install this module directly on the console of your hosting environment. Make sure to `cd` into your root folder of the shop, prior.

shell
composer config repositories.swissup composer https://docs.swissuplabs.com/packages/
composer require swissup/module-search-mysql-legacy --prefer-source --ignore-platform-reqs
bin/magento module:enable Swissup_SearchMysqlLegacy Swissup_Core
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento indexer:reindex catalogsearch_fulltext

But you can also run some other nice things with this module being there, like install Magento 2.4 without ElasticSearch in the first place:

shell
php bin/magento setup:install --disable-modules=Magento_InventoryElasticsearch,Magento_Elasticsearch7,Magento_Elasticsearch6,Magento_Elasticsearch

Afterwards, just enable the modules again:

shell
php bin/magento module:enable Magento_Elasticsearch Magento_Elasticsearch6 Magento_Elasticsearch7 Magento_InventoryElasticsearch


How can I check current search engine?


You can check your current search engine in your Magento 2.4 shop with and without this module installed using:

shell
php bin/magento config:show catalog/search/engine

How can I change search engine?


You can change your current search engine in your Magento2.4 application with this module installed using:

shell
php bin/magento config:set catalog/search/engine 'lmysql'


Are you a bit overwhelmed by it?


No problem - if you feel overwhelmed by it and you're not sure how to do it, or if you just want to save costs, you can always contact us to install this module in your shop. Just send us a message via our contact form or just click the button below.