This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How to Install and Configure Elasticsearch on Magento 2 (A Step-by-Step Guide)

Updated on September 28, 2022

10 Min Read
Magento Elasticsearch

Magento stores without effective real-time search results for the customers can drop your conversions. This is where Elasticsearch comes in!

Ecommerce developers continuously work to introduce technologies and components that directly improve user experience, and Magento is no different. For ecommerce stores, customer searches increase with smart and short words and expect faster results based on their product search.

Magento 2 Elasticsearch is one such component that improves the user journey. It makes it easy for users to find the right product almost immediately, close the transaction within minutes and thus have a great shopping experience. Magento recommends installing Elasticsearch on earlier versions of Magento 2.3.x, but a required component in Magento 2.4.x with predefined configurations.

This blog will cover how to install Elasticsearch using SSH and configure it using the Magento 2 admin panel.

What is Magento Elasticsearch?

Elasticsearch was introduced as a full-text search solution that suggests related keywords and shows complete queries based on the query. However, Elasticsearch is not just limited to search queries. It can also be used to set up store-wide search capabilities.

Magento 2 Elasticsearch is a server-based tool capable of a very high speed of full-text search. Powered by Apache Lucene (an open-source full-text search library), it offers a fast web content search capability. The fast response is the indexing service used for contextual search instead of searching the entire database for the match. Magento Elasticsearch suggests related products, images, prices, ratings, and information to narrow the search results. The search filter and suggestions are based on the Magento 2 Elasticsearch configuration, which I will discuss later in this article.

Advantages of Magento 2 Elasticsearch

According to Microsoft, the attention span of an average user has gone down to just 8 seconds. Given this, online retailers must be able to sell quickly within this window.

Another related fact is that the longer users spend on your site, the less likely they will buy something. Think of it this way: Why would anyone stay in a store if the salesperson keeps showing things you do not want?

Elasticsearch keeps your Magento store’s search functionality precise and fast for your potential customers. This enhances the customer’s experience and lets them make good use of their time in your store.

Some additional benefits of configuring Elasticsearch in the Magento 2 store are:

Display Products: Besides handling complex queries, Elasticsearch can easily display the products and their attributes for all related search queries to help customers.

Response Times: Due to implemented cache Elasticsearch can retrieve the results in a few seconds and also improve response times, especially when you have a large data volume.

Improve Conversions: Elasticsearch’s architecture flexibility can improve conversion and grow your revenue by displaying related information that helps make a better purchase decision.

Elasticsearch on Magento 2 comes with a host of features such as:

  • Search optimization
  • Search autocomplete
  • Thesaurus management (synonyms, expansions)
  • Advanced price slider
  • Multi-select in layered navigation & swatches
  • Redirection to the product page in case of single results
  • Auto spell check & stopwords detection
  • Customizable filters
  • Multiple languages supported
  • Real-time data and analysis

Supercharged Magento Hosting With Elasticsearch

With Elasticsearch on your Magento store, your customers find products faster and convert more frequently.

Prerequisites for Setting Up Elasticsearch?

Now that you have understood the need for Elasticsearch, let’s look into the prerequisites for configuring the module for different Magento versions.

Magento Elasticsearch Requirement

According to the official Magento release, Elasticsearch 2.x and early 5.x versions are outdated and you need to upgrade to a later version of 5.x. If you have the latest Magento version (2.4.x), you should opt for Elasticsearch 7.6.x.

In addition to a compatible Magento Elasticsearch version, you should also have:

Release of Magento 2.4 and Elasticsearch Note

Before we go into details about Magento Elasticsearch, we must know that Magento 2.4 was initially introduced in 2020, but now Adobe has officially announced that Magento 2.4 will be entering End of Life (EOL). Official support for this release of Magento will end on September 8, 2022.

Before Magento 2.4, Elasticsearch was the required component in installing Magento modules. It is to be notified that in Magento 2.4 Admin, the catalog search will no longer be used by MySQL. Instead, the system will use Elasticsearch by default. Elasticsearch service is deployed for rapid search results, scaling and optimizing the storing function for full-text search, and outreach the analytics.

Configure Server for Magento 2.4 Elasticsearch

You can quickly set up Elasticsearch on your Magento store by following the process below. For the purpose of demonstrating the process, I will use my Cloudways managed Magento server. This means I have an active server on the Cloudways Platform with an active Magento app.

Let’s start.

Launch Server on Cloudways

The best part of configuring Magento Elasticsearch with Cloudways is that you can install Elasticsearch in a few clicks without going to the CLI.

Let’s see how easily you can launch your Cloudways managed Magento server and install Elasticsearch.

  • Log in/sign up to the Cloudways Platform.

Cloudways platform sign up

  • Select Magento Application from the drop-down menu. Next, name your application and server.

Magento 2 Elasticsearch 1

  • Select the Cloud Provider of your choice from the available cloud infrastructure options.

Choose Cloud Providers for Magento application

  • Choose server size based on your needs. You can always scale the server whenever you realize that server resources are running low.

Select Server Size

  • Select a server location nearest to your audience. For each cloud provider, you have the option of multiple data centers.

Choose Nearest Server Location for Magento Application

Now click the Launch Now button and wait for a few minutes while the server and the application are set up.

Enable Elasticsearch

After successfully configuring the Cloudways managed server, you need to enable Elasticsearch on the server. For this, go to the Settings & Packages tab on the Server Management screen.

Magento 2 Elasticsearch 2

Elasticsearch is now enabled on your server.

Now let’s go over the Magento 2 Elasticsearch configuration process.

With Magento 2 latest version, Elasticsearch has become a default, greatly simplifying the configuration and store-level integration requirements.

I will now demonstrate the ease with which you can set up Elasticsearch with your Magento 2 store.

Install Elasticsearch via SSH

In this process, we will install Elasticsearch with SSH access after your application’s server setup on Ubuntu. Please Note we assume your application is already set up on Ubuntu or any other hosting server. Let’s get started!

  1. Connect to SSH
  2. Install Java (JDK) on Ubuntu
  3. Install From the Apt Repository
  4. Download the Elasticsearch With Debian Package
  5. Install the Elasticsearch
  6. Run the Elasticsearch Service

Step 1: Connect to SSH

We must connect the Magento application to SSH/SFTP through PuTTY for Windows or a terminal for Ubuntu. For SSH access, please check the complete guide through Guide to Connecting to Your Application Using SSH/SFTP.

To access SSH in the Cloudways Platform, go to Server Management → Master Credentials.

magento-elasticsearch-ssh-access

Open PuTTY and enter the details:

magento-elasticsearch-putty

Enter the following details:

  • IP: your SSH IP
  • Username: master_cyxzkqxzc
  • Password: **********

magento-elasticsearch-access

Step 2: Install the Java (JDK) on Ubuntu

Assume that our server is installed on Ubuntu. First, check Java is installed by the command: java –version

magento-elasticsearch-java

If the command return message displays java: command not found, you just need to install JDK as we will install JDK next.

Run the following commands with root privileges:

sudo apt-get -y update

sudo apt install openjdk-8-jdk.

For other versions, see Oracle documentation.

magento-elasticsearch-jdk

Recheck the java –version to confirm the status.

Step 3: Install From the APT Repository

Before we move on to install the Elasticsearch, we need to proceed with installing the apt-transport-https on the server. Run the below command:

sudo apt-get install apt-transport-https

magento-elasticsearch-repo

Step 4: Download the Elasticsearch With Debian Package

The Debian package for Elasticsearch from the website. Download and install Elasticsearch by the following command:

wget https://artifacts.elastic.co/downloads/Elasticsearch/Elasticsearch-7.6.0-amd64.deb

Please note that Elasticsearch 5.0.X and 6.0.X version is now deprecated.

magento-elasticsearch-debain

Then run the following command to save keys:

wget https://artifacts.elastic.co/downloads/Elasticsearch/Elasticsearch-7.6.0-amd64.deb.sha512

magento-save-keys

Next, to save the files downloaded to the installed directory, run the following command to ensure the files are saved:

shasum -a 512 -c Elasticsearch-7.6.0-amd64.deb.sha512

magento-elasticsearch-save-ok

Message displays: Elasticsearch-7.6.0-amd64.deb: OK

Step 5: Install the Elasticsearch

Next, we will install the Elasticsearch Package downloaded in the previous step. Use the below commands to install:

sudo apt-get update

sudo apt-get install Elasticsearch

magento-install-elasticserach

Step 6: Run the Elasticsearch Service

To configure and start the Elasticsearch service automatically, run the following commands to ensure the service starts:

sudo /bin/systemctl daemon-reload

sudo /bin/systemctl enable Elasticsearch.service

To start or stop the Elasticsearch service run the below command: 

sudo systemctl start Elasticsearch.service

sudo systemctl stop Elasticsearch.service

These commands can start the Elasticsearch Magento service and save the logs in the /var/log/Elasticsearch/ directory.

To check the status of the Elasticsearch service, run the following command:

service Elasticsearch status

Configure Magento 2 Elasticsearch

Now let’s go over the Magento 2 Elasticsearch configuration process. With Magento 2 latest version, Elasticsearch has become a default, greatly simplifying the configuration and store-level integration requirements.

I will now demonstrate the ease with which you can set up Elasticsearch with your Magento 2 store.

Here’s the simple process of setting up Magento 2 Elasticsearch

  • Log in to the Magento Admin as an Administrator.
  • Click Stores > Settings > Configuration > Catalog > Catalog

Magento Catalog Search

  • Then go to Catalog Search section

Magento 2 Elasticsearch 3

  • In Minimum Query Length, enter the query length at which Magento 2 Elasticsearch will get enabled.
  • In Maximum Query Length, enter the length of the query for which Magento 2 Elasticsearch would remain enabled.
  • In the Number of top search results to cache, enter the number of popular searches that the module should store for faster response.
  • Next, Enable EAV Indexer to Yes to improve indexation speed.
  •  Set the Search Engine to either Elasticsearch 5.0+, Elasticsearch 6.0+ or Elasticsearch 7 (Recommended). It is recommended to Use System Value because it automatically picks server packages for the configuration.
  • In Autocomplete Limit, enter the maximum limit for similar suggestions for each query.

catalog search 2 Magento Elasticsearch

  • In Elasticsearch Server Hostname, enter the fully qualified hostname or IP address of the server that is running the Magento 2 Elasticsearch.
  • In Elasticsearch Server Port, enter the Magento 2 Elasticsearch server proxy port. If ‘9200’ does not work for you, try ‘8080’. If you’re using a secure proxy, you can also use port ‘443’.
  • Elasticsearch Index Prefix: You can use the default prefix magento2 but if you use a single Elasticsearch instance for more than one Magento installation, you will have to specify a unique prefix for each installation. This is because Magento has a multi-store inventory feature, and if a single Elasticsearch is used for all stores, it would be difficult to distinguish between the stores.
  • To Enable Elasticsearch HTTP Auth, select Yes. Next, provide a username and password in the specified fields. It is recommended that you keep it to No.

In Elasticsearch Server Timeout, define the time after which your Magento 2 Elasticsearch server would time out. The time is in seconds.

Magento 2 Elasticsearch 5

  • Enable Search Suggestions to Yes if you want to show suggestions in your Elasticsearch search space.
  • In Search Suggestions Count, define the count for search suggestions. On average, two suggestions are displayed with each search.
  • If Show Results Count for Each Suggestion is selected as Yes, the count for each suggestion would be displayed.
  • If you Enable Search Recommendations to Yes, recommendations will be displayed for search strings.
  • In Search Recommendations Count, define the count for search suggestions.
  • If Show Results Count for Each Recommendation is selected as Yes, the result count would be displayed with each suggestion.

Magento 2 Elasticsearch 6

Summary

Once your Magento 2 Elasticsearch configuration is complete, your Magento store will be ready to generate more sales and less cart abandonment. If you still don’t have a managed store hosted on Cloudways, it’s time for you to join the next stage of the evolution of Magento ecommerce hosting.

Frequently Asked Questions

Q: What is Magento Elasticsearch?

A: Magento Elasticsearch is a store-level search engine that delivers store-wide search results so that visitors can quickly see the list of products they wish to buy. Magento Elasticsearch is a fantastic tool for offering related products and deploying upsell and cross-sell tactics for store owners.

Q: How does Magento Elasticsearch work?

A: Magento Elasticsearch relies on several data sources, including logs and a database. Once the data has been parsed, it is added to the Elasticsearch index. Now, store owners can execute complex queries to take advantage of the indexed data to deliver precise information in response to user-generated searches.

Q: Why is Magento 2 Elasticsearch fast?

A: Magento 2 Elasticsearch is significantly faster than traditional search engines because it works. Instead of searching the raw data in response to user queries, Elasticsearch searches its index significantly faster because the data in the index is normalized and optimized for the search process.

Q: Is Elasticsearch free?

A: Elasticsearch is free to use because it is free and open-source software.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Great speed, features, knowledgebase, dashboard, UX and fast, expert support. Very happy!”

Stefan [Management Consultant]

Jyotishna Kumari

Jyotishina is the Magento Community Expert at Cloudways and has 4 years of experience in web development. She has worked on e-commerce sites since the turn of the millennium and was working with Magento before version 1 was released. She loves to travel and explore new ideas whenever she finds time. Get in touch with her at [email protected]

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Unleash The Cloud.
Not Budgets.

For 4 Months +
Up To 30 Free Migrations

Cyber Week

SAVINGS
Time Left In Offer
  • 0

    Days

  • 0

    Hours

  • 0

    Minutes

  • 0

    Seconds

40% OFF

On All Plans

GET THE DEAL NOW