Well, we just guess that for most of us Elasticsearch is not a new tag, that’s best. But, for the one to whom this word sounds strange, need not worry, as we are here to help you out.

Before we jump onto the steps of installation of Magento 2.4 with Elasticsearch, let’s first know about Elasticsearch, its birth, its uses, benefits, and more. This will assist you with the thorough knowledge of Elasticsearch that would be required while moving deeper.

Release of Magento 2.4 – Key Highlights & Emergence of Elasticsearch

Magento 2.4 has been released to enhance the security, for better security payment gateways, performance, inventory or stock management, and for resolving existing issues. The highlights of Magento 2.4:

  • Security Patches
  • Platform Upgrades
  • Infrastructure Improvements
  • Performance Improvements
  • Purchase Approval Workflows
  • Seller-assisted shopping
  • In-Store Pickup
  • New Media Gallery
  • PWA Improvements

Well, we will now know how Elasticsearch came into existence. In Magento 2.4, the platform upgrades will enhance the performance of Magento store along with its security. It will be supported by PHP 7.4. Moreover, there is also the support for PHPUnit 9.x, Elasticsearch 7.6.x support, and MySQL 8.0 support. The MySQL catalog search engine has been removed and it has been replaced by Elasticsearch default search engine. For more visit here- Magento Open Source 2.4 Release Notes

Earlier Options for Deploying Elasticsearch

Before the release of Magento 2.4, and now as well, Elasticsearch is deployed as managed, hosted service all through Elasticsearch Service. Moreover, it is permitted to download and install on our hardware or in the cloud. The one who needs to provision, handle, and monitor his deployments from a single code, but choose not to use a public cloud platform, Elastic provides Elastic Cloud Enterprise and Private subscription tier.

What Is Elasticsearch?

A RESTful, distributed search, and analytics engine, Elasticsearch is capable of locating an expanding number of use cases. Being a heart of the Elastic Stack, Elasticsearch stores your data centrally for rapid search, powerful analytics, and fine-tuned relevancy that just scale easily. Simply, we can say, the Elasticsearch aids in storing and mapping all documents effectively to optimize the search and the retrieval function.

A powerful, open-source analytic and search engine, Elasticsearch uses Apache Lucene. Apart from handling a large number of use cases, it supports various tenancies along with a full-text search on the HTTP web interface.

Benefits of Elasticsearch


As Elasticsearch is developed on the top of Lucene, it is best at full-text search. Moreover, it is a near real-time search platform, which states that the latency from the time when a document is indexed until it gets searchable, is very short, typically of one second. Resultantly, Elasticsearch suits the best for the time-sensitive use cases, like infrastructure monitoring and security analytics.

Distributed Nature

The documents that are stored in Elasticsearch are distributed all across the different containers namely, shards that are duplicated to offer redundant copies of the data, when hardware fails. Its distributed nature permits it to scale our lots of (hundreds and thousands) of the servers and handle the petabytes of data.

Furthermore, Elasticsearch arrives with a broad set of features. Additionally, other than its scalability, speed, and resilience, Elasticsearch holds a number of robust built-in features that lead to more efficient storing and searching of data, like data rollups and index lifecycle management.

Elastic Stack eases data ingest, reporting, and visualization

Integration with Logstash and Beats makes it simple to process data before indexing into the Elasticsearch. Also Kibana offers real-time visualization belonging to Elasticsearch data and UIs for rapidly accessing application performance monitoring (APM), infrastructure metrics data, and logs.

Why Use Elasticsearch In Magento 2?

In every eCommerce website, embracing the ones developed on Magento 2, undoubtedly, the search is one of the most pivotal functionalities. An effective search will aid the shoppers to pull out their required products in the store easily that might lead to better-stimulated purchases and customer experience.

On the other edge, the poor search tool holds the power to slow down the process of searching the items and also be the reason behind bounce rates of the high buyers. That’s why it’s imperative to have the search features in Magento 2 stores, and applying the Elasticsearch is one of the perfect ways to perform that.

Unfortunately, Magento just integrates Elasticsearch in Magento commerce edition and Magento Open Source 2.3.0.

For Magento Open Source 2.2.x, you are required to install a proper module to hold powerful features of Elasticsearch. Now, there exist various options when it’s the turn of Magento 2 Elasticsearch module, both paid and free.

Also Read: How to Hire A Magento 2 Developer – Complete Guide

Uses of Elasticsearch

The scalability and speed of Elasticsearch and its caliber to index various types of content states that it can be employed for a number of use cases:

  • Website search
  • Application search
  • Enterprise search
  • Infrastructure metrics & container monitoring
  • Logging & log analytics
  • Application performance monitoring
  • Security analytics
  • Geospatial data analysis & visualization
  • Business analytics

Now, we will move onto the process of Magento 2.4 Installation with Elasticsearch. Let’s get started.

Install Apache2 on Ubuntu

First, we need to install a lamp setup via the command line. I have using apache2 for a webserver.

Apache HTTP webserver provides many powerful features, including dynamically loadable modules, robust media support, and extensive integration with other popular software.

Step 1 – Install Apache2

# apt-get update

1 apt-get update

# apt-get install -y apache2

2 apt-get install -y apache2

Step 2 – Firewall Allow

# ufw app list

3 ufw app list

# ufw allow 'Apache'

4 ufw allow apache

# ufw status

5 ufw status
When firewall status inactive then we need to enable it.

# ufw enable

6 ufw enable

# ufw status

7 ufw status

Step 3 – Check Web Server

# service apache2 status

8 service apache2 status
Go to Browser and browse with private ip. You should see the default Ubuntu 18.04 Apache web page:9 the default Ubuntu 18.04 Apache web page

Install MySQL on Ubuntu

An open-source database management system, MySQL is commonly installed like a part of the famous LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It employs a relational database along with SQL (Structured Query Language) to handle its data.

Step 1 – Install MySQL

# apt-get update

10 apt-get update

# apt-get install mysql-server

apt-get install mysql-server

Step 2 – Configuring MySQL

11 Configuring MySQL
Enter a three level of password validation and also given a root password:12 three level of password validation

# mysql

13 mysql

Step 3 – Create a MySQL User

Creating a new user and give it a strong password.

mysql> CREATE USER 'magento'@'localhost' IDENTIFIED BY 'magento123';

14 CREATE USER magento localhost
you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'magento'@'localhost' WITH GRANT OPTION;

15 magento localhost



mysql> exit;

Step 4 – Testing MySQL

# systemctl status mysql

17 systemctl status mysql

Install PHP7.3 on Ubuntu

Step 1 – Install PHP

# apt-get install software-properties-common

18 apt-get install software-properties-common

# add-apt-repository ppa:ondrej/php

19 add-apt-repository ppa ondrej

# apt-get update

20 apt-get update

# apt-get install -y php7.3

21 apt-get install -y php7.3

# php -v

22 # php -v

Step 2 – Installing PHP module

# apt-get install -y php7.3 libapache2-mod-php7.3 php7.3-curl php7.3-gmp php7.3-mbstring php7.3-phpdbg php7.3-sqlite3 php7.3-zip php7.3-bcmath php7.3-dba php7.3-imap php7.3-pspell php7.3-sybase php7.3-bz2 php7.3-dev php7.3-interbase php7.3-mysql php7.3-readline php7.3-tidy php7.3-cgi php7.3-enchant php7.3-intl php7.3-odbc php7.3-recode php7.3-xml php7.3-cli php7.3-fpm php7.3-json php7.3-opcache php7.3-snmp php7.3-xmlrpc php7.3-common php7.3-gd php7.3-ldap php7.3-pgsql php7.3-soap php7.3-xsl php7.3-mongo

23 Installing PHP module

Install & Setup Magento 2.4

Step 1 – Create directory and download magento2.4 file

Create a directory
24 Create a directory
Download Magento-CE-2.4.0 on official website.
25 Download Magento-CE-2.4.0
After downloading unzip zip file in this folder.

Step 2 – Given Permission

# chmod -R 755 magento2.4

26 chmod -R 755 magento2.4

# chown -R magento:magento magento2.4

27 chown R magento magento magento2.4

# chmod -R 777 var pub generated app

28 chmod -R 777 var pub generated app

Step 3 – Magento Installation

Magento2.4 installation via command line. So we have to create a database and mysql user already then run command below:

# php bin/magento setup:install --base-url=http:// --db-host=localhost --db-name=magento --db-user=magento --db-password=magento123 --admin-firstname=test --admin-lastname=test [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

29 Magento2.4 installation

Install Elasticsearch on Ubuntu

Step 1 – Install Java (Its necessary for dependencies)

# apt-get update

30 apt-get update

# apt install openjdk-8-jdk

31 apt install openjdk-8-jdk

# java -version

32 java -version

Step 2 – Installing from the APT repository

# sudo apt install apt-transport-https

33 sudo apt install apt-transport-https

Step 3 – Install and Download Elasticsearch

34 Install and Download Elasticsearch
35 echo deb

Step 4 – Install Elasticsearch

# apt-get update

36 apt-get update

# apt-get install elasticsearch

37 apt-get install elasticsearch

Step 5 – Start Elasticsearch Service

# systemctl daemon-reload

38 systemctl daemon-reload

# systemctl enable elasticsearch.service

39 systemctl enable elasticsearch.service

# systemctl start elasticsearch.service

40 systemctl start elasticsearch.service

# service elasticsearch status

41 service elasticsearch status

Step 6 – Configure Elasticsearch

The default configuration doesn’t permit your machine to be accessed by other hosts. To allow remote access, use a text editor you want and open the elasticsearch.yml file
42 Configure Elasticsearch

43 default configuration

Step 7 – ufw to Secure Elasticsearch

# ufw allow 22

44 ufw allow 22

# ufw enable

45 ufw enable

# ufw status

46 ufw status

Step 8 – Test Elasticsearch

# curl localhost:9200

47 Test Elasticsearch

Elasticsearch Configuration in Magento

Step 1 – Configure Search Options

1. From the Admin sidebar, select Stores. Then under Settings, select Configuration.
48 Configure Search Options
2. In the panel on the left of the screen, under CATALOG, select Catalog.
49 CATALOG, select Catalog.
3. Click to Catalog Search to expand this section.
50 Catalog Search
4. In the Search Engine field, clear the Use system value checkbox and select the version of Elasticsearch that is installed on your server.51 Search Engine

Step 2: Configure the Elasticsearch Connection

52 Configure the Elasticsearch Connection

    • 1. Enter the Elasticsearch Server Hostname. The default is localhost
    • 2. Enter the Elasticsearch Server Port.
    • 3. Enter a prefix in the Elasticsearch Index Prefix field to determine the Elasticsearch index. For instance: Magento2.
    • 4. In the Enable Elasticsearch HTTP Auth field, select Yes option to use HTTP authentication to suggest a username and password access Elasticsearch Server.

53 Enable Search Suggestions

  • 5. Enter the number of seconds before the system times out to the Elasticsearch Server Timeout field. The default number is 15.
  • 6. To verify the configuration, click to the Test Connection button.

Step 3: Configure Suggestions and Recommendations

1. In the Enable Search Suggestions field, choose the Yes option. Then, take the following actions:

  • Fill the Search Suggestions Count field with the number of search suggestions to offer.
  • In the Show Results for Each Suggestion field, select Yes option to display the number of results found for each suggestion.

2. In Enable Search Recommendations field, select Yes option to offer recommendations.

  • Fill the Search Recommendation Count field with the number of recommendations to offer.
  • In the Show Results Count for Each Recommendation field, select Yes to display the number of results found for each recommendation.

3. When you finish your configuration, click to the Save Config button.

Avatar photo

CTO at Emizentech and a member of the Forbes technology council, Amit Samsukha, is acknowledged by the Indian tech world as an innovator and community builder. He has a well-established vocation with 12+ years of progressive experience in the technology industry. He directs all product initiatives, worldwide sales and marketing, and business enablement. He has spearheaded the journey in the e-commerce landscape for various businesses in India and the U.S.