How to Configure ElasticSearch in Magento 2 the Right Way?

Magento is an advanced, open-source eCommerce platform built in PHP. This powerful eCommerce platform powers over 170,000 online stores on the internet. If you want to develop your online store in Magento, you can approach a Magento 2 development company to build your store from scratch. To make your eCommerce store highly interactive with the end-user, you should integrate it with a powerful search engine like ElasticSearch. ElasticSearch is a search engine that can search text searches. ElasticSearch is Freeware, so it is free to use, however, the code cannot be distributed under another name. It is the search engine known for its REST APIs, scalability options for large data sets, distributed nature, and versatility it offers. ElasticSearch search engine processes, analyzes, assesses, and maps data to use it to its maximum potential. This article will guide you on how to configure ElasticSearch in Magento 2 the right way.

If you’re less tech-savvy, you can hire Magento developers from us who can help you integrate ElasticSearch with your Magento store properly.

Why Should You Use ElasticSearch in Magento 2?

In any eCommerce website, search functionality plays a critical role in enhancing the overall user experience. A poor search tool can reduce the pace of the product search process and result in higher bounce rates. On the other hand, an effective search will enable customers to find their desired products on the online store easily which further leads to a better customer experience and increased sales.

How to Configure ElasticSearch in Magento 2 the Right Way

Therefore, it is important to enhance the search functionality in Magento stores, and integrating ElasticSearch is one of the best ways to address this. However, Magento only integrates ElasticSearch in Magento Open Source 2.3.0 and Magento Commerce edition. For Magento Open Source 2.2.x versions, you will need to install a module to leverage the powerful features of ElasticSearch.

Now, let’s take a look at how to configure ElasticSearch in Magento 2.

Configure ElasticSearch in Magento 2 – A Step-by-Step Guide

Install ElasticSearch

Installation on UNIX and Linux-based Systems:

  1. First, make sure that Java is installed on your system and then install OpenJDK or OracleJDK.
  2. Next, run the following commands sequentially:
  • %09https:/
  • shasum%20-a%20512%20-c%20elasticsearch-7.15.2-linux-x86_64.tar.gz.sha512
  • tar%20-xzf%20elasticsearch-7.15.2-linux-x86_64.tar.gz
  • cd%20elasticsearch-7.15.2/

The first three commands compare the SHA of the downloaded .tar.gz file archive the published checksum, which displays:

  • %09https:/
  • shasum%20-a%20512%20-c%20elasticsearch-7.15.2-linux-x86_64.tar.gz.sha512
  • tar%20-xzf%20elasticsearch-7.15.2-linux-x86_64.tar.gz
  • cd%20elasticsearch-7.15.2/

The fourth and fifth commands are a directory named $ES_HOME.

Installation on Mac OS

Run the following commands in the given sequence:

  1. wget%20https:/
  2. wget%20https:/
  3. shasum%20-a%20512%20-c%20elasticsearch-7.15.2-darwin-x86_64.tar.gz.sha512
  4. tar%20-xzf%20elasticsearch-7.15.2-darwin-x86_64.tar.gz
  5. cd%20elasticsearch-7.15.2

The first three commands compare the SHA of the downloaded .tar.gz file archive the published checksum, which shows the following:


The fourth and fifth commands are a directory called $ES_HOME.

Download and Install ElasticSearch on Windows Usin .zip.

You can activate ElasticSearch on Windows using the .zip archive. This comes with a command that makes ElasticSearch run as a service.

  1. You will need to first download the .xip archive for your ElasticSearch v7.15.2 from the following website:

  1. Next, you will need to unzip the file using WinRar, 7Zip, or any unzip tool. This will create a new folder named as ElasticSearch- 7.15.2 that is referred to as %ES_HOME%.
  2. Activate the formation of the system indices. By default, ElasticSearch is configured to automatically enable index creation. However, if you don’t activate the automatic index creation, you need to configure the action.auto_create_index in the elasticsearch.yml and then let the commercial features install the following indices:


  1. After that, run the command line as follows on your command prompt: \bin\elasticsearch.bat.

If your ElastucSearch Keystore is protected by a password, you will need to enter the key store’s password that you’ve set. By default, ElasticSearch prints the logs to the console command of STDOUT and also to <clustername>.log within the logs directory.

When the ElasticSearch boots up, it logs some data. After it is installed, it can be used in the foreground and will not log data until a significant event occurs. When the search engine is enabled, you can interact with the HTTP interface which is on port 9200, by default.

You can terminate ElasticSearch by pressing Ctrl-C on your keyboard.

  1. Next, you need to configure ElasticSearch in Magento 2on the command line. The search engine will load its configuration from the %ES_HOME%\config\elasticsearch.yml file by default. Whatever setting is specified as config will late be specified on the command line, using syntax of –E. For instance, .\bin\elasticsearch.bat
  2. After that, you need to check if ElasticSearch is running by sending an HTTP request to the 9200 on localhost:

GET/. This will return a response that will define the name, class and cluster, and more.

  1. Now install ElasticSearch in Magento 2 as a service on Windows. ElasticSearch can be installed as a service that can run in the background and automatically initiate at boot time irrespective of the user interaction. This can be done by accessing the ElasticSearch-service.bat script in the bun\ folder. This can install, configure, manage, and remove the services from the command-line interface.

If you find enabling the services to be a challenging process, you can hire Magento developers from us for Magento support services.

How to Configure ElasticSearch in Magento 2?

Now that you have installed ElasticSearch on your system, you need to set up and configure ElasticSearch in Magento 2. ElasticSearch already set up the system according to the default settings.

Here are the steps that you can follow to configure with Magento:

  • Log in to your Magento 2 store account on Admin.
  • Click on stores -> setting -> configuration -> catalog -> select catalog search
  • Now, select your installed ElasticSearch version from the search engine list.

If you have configured the setting, these configuration options will help you to set up Magento 2.

  • Elasticsearch Server Hostname: Input the IP address of your system that will run the ElasticSearch.
  • Elasticsearch Server Port: Next, you need to enter the ElasticSearch web server’s proxy port. 9200 is the default port.
  • ElasticSearch Index Prefix: Input the index prefix for ElasticSearch. If you’re using a single instance of ElasticSearch for multiple Magento stores, you will need to specify a unique prefix for each installation.
  • Enable ElasticSearch HTTP Auth: Click yes only when you have enabled the authentication for your ElasticSearch server. You will need to enter your username and password in the fields.

How to Test Your Search?

The next step is to test your connection by clicking on the test connection button. If it indicates ‘Successful! Test again?’, you can move ahead to configuring Apache and ElasticSearch if required.

If it’s ‘Connection failed! Try again?’, then you can follow the below-given steps to set your connection properly

  • Make sure that the ElasticSearch server is running on the backend by executing this command \bin\elasticsearch.bat on the backend.
  • If the ElasticSearch server is not on the host from Magento, you need to log in to the Magento server and ping the ElasticSearch host.
  • This will fix the issues related to the network connectivity and then you can click on the test the connection button.
  • Check the command prompt, where you had started the ElasticSearch to find stack traces and exceptions. Make sure to fix this before you proceed by ensuring that you have started ElasticSearch as a user who can access the root.
  • Also, see if both the UNIX firewall and SELinux are deactivated. You can check if the setup rules allow ElasticSearch to communicate with Magento.
  • Check the value of the ElasticSearch Server Hostname and ensure that it is valid. Make sure that the server is available; you could even try your server’s IP address.

Highlights of Magento 2 ElasticSearch

  • Thesaurus management (synonyms, expansions)
  • Search optimization
  • Search autocomplete
  • Advanced price slider
  • Multi-select in layered navigation and swatches
  • Redirection to the product page in case there is only one result
  • Auto spell checking and detection of stopwords
  • Customizable filters
  • Search under different languages
  • Real-time data and analysis

Wrapping Up

If you’ve indulged in Magento 2 development, you can configure ElasticSearch in Magento 2 to improve your overall customer experience. Magento 2 ElasticSearch is a robust integration that can help you increase your customer base. It can help you build a Magento store that is capable of satisfying every customer uniquely.

You should hire a professional Magento eCommerce development company that can provide robust Magento eCommerce solutions. As a leading Magento 2 development company, we have a team of certified Magento 2 developers who have extensive experience in the domain. We offer affordable packages for Magento 2 pricing and include Magento support services that you can use to stay competitive in the eCommerce market.

Frequently Asked Questions


Q. What is ElasticSearch in Magento 2 and how does it work?

Magento 2 ElasticSearch is a powerful integration of the Magento 2 eCommerce platform and the ElasticSearch search engine. This integration enables customers to find what they are looking for quickly and ensure that they are able to find items even if they are not sure of the exact requirements. Integrating ElasticSearch in Magento 2 enhances data manageability and ensures effective use of resources. Also, with an additional layer of security and protection, the users can secure the data from cyber threats and ensure that the data is safe.

Q. What is Magento Sphinx Search vs Magento ElasticSearch?

Ans. SphinxSearch is a free, open-source full-text search server built with keeping performance, search quality, and seamless integration in mind. On the other hand, ElasticSearch is a search engine created on the Apache Lucene library. It provides a reliable text search engine along with an HTTP web interface.

You may also read Magento Sphinx Search vs Magento ElasticSearch to discover the key differences.

Need Help with Magento 2 ElasticSearch Integration?

Talk To Experts