Get a Free Consultation

    Search for:

    Magento 2 Elasticsearch: How to Configure Magento 2 ElasticSearch?

    Last Updated | August 17, 2023

    Magento 2 Elasticsearch

    Magento is no different from other eCommerce platform developers in their ongoing efforts to include technology and elements that directly enhance user experience. Magento 2 Elasticsearch is one such element that enhances the user experience. It makes it simple for users to quickly select the ideal product, complete the transaction within minutes, and enjoy a wonderful shopping experience.

    Magento development

    What is Magento?

    Magento is an open-source eCommerce platform that gives online retailers control over their online store’s appearance, content, and operation in addition to a versatile shopping cart system. Magento provides robust capabilities for catalogue management, search engine optimization, and marketing.

    Magento was created so that non-developers could use it as an application. The Magento community is enormous and incredibly supportive. However, the typical person will eventually run into a brick wall.

    What is Elasticsearch?

    Elasticsearch is a decentralized, open-source, cost-free search and analytics platform for text, numbers, geographic, structured, and unstructured data. Built on Apache Lucene, Elasticsearch was first made available in 2010 by Elasticsearch N.V. currently known as Elastic.

    Elasticsearch, the centerpiece of the Elastic Stack, a collection of free and open technologies for data intake, enhancement, storage, analysis, and visualization, is renowned for its straightforward REST APIs, and decentralized nature, speed, and scalability.

    The Elastic Stack, often known as the ELK Stack after Elasticsearch, Logstash, and Kibana, now supports a wide range of lightweight shipping agents called Beats for transmitting data to Elasticsearch.

    Elasticsearch was presented as a full-text search solution that not only displays complete searches depending on the query but also provides related terms. Elasticsearch, however, is not merely for conducting searches. It could also be used to set up capabilities for store-wide searching.

    What is Magento 2 Elasticsearch?

    Magento 2 Elasticsearch, a server-based tool, which is extremely quick with full-text search capabilities. It allows quick web content searching through the use of Apache Lucene, an open-source full-text search library. Rather than querying the complete database structure for the match, contextual search uses an indexing service, which is the reason for the quick response.

    The search process is similar to the index of a book. Similar to a book index, the matching starts from the initial part of the query and the results are refined as the query is entered. So as soon as the user starts entering the search string, Elasticsearch starts producing matches.

    Magento 2 Elasticsearch starts suggesting related products, along with images, prices, ratings, and related information to narrow down the search results. The search filter and suggestions are based on the Magento 2 Elasticsearch configuration which I will discuss later in this article.

    Magento integration

    What are the benefits of Magento 2 Elasticsearch?

    Let’s talk about some of the key advantages of Magento 2 Elasticsearch

    • Enhanced Performance

    Through its distributed inversion indices, Elasticsearch is capable of carrying out incredibly quick searches.

    In other words, Elasticsearch is good at catching all search terms for the result set, and it would then direct the query for the result from the caches whenever a search contains a cached filter.

    As a consequence, it can obtain the results of a search in less than 10 milliseconds, which is much quicker than the standard SQL database, which can take up to 10 seconds to do so.

    • High Scalability

    Elasticsearch can grow up to several thousand servers and thousands of gigabytes of storage because it is built on a distributed architecture.

    Additionally, it is built so that it may function properly on any cluster or system with numerous nodes.

    As a result, scaling just requires a little forethought when going from a solitary small cluster to a bigger or even massive cluster.

    • Distributed Architecture

    Elasticsearch is capable of managing enormous volumes of data thanks to its distributed architecture, making it the ideal inner website’s search engine for handling search queries.

    The indices are essentially split into shards by Elasticsearch’s distributed design, and the tach fragment is capable of producing an infinite number of replicas.

    This means that the sequencing and rebalancing actions are carried out automatically each time new documents are uploaded to the database.

    • Document-Oriented Database

    JSON refers to Javascript Object Notation, which is what Elasticsearch makes use of.

    In essence, it’s a serialization format for documents that stores complicated entities and indexes every item by itself.

    In reality, JSON is currently compatible with many other programming languages and is a well-liked and extensively utilized language for NoSQL databases.

    It is a very succinct, straightforward, and easy-to-read serialization format, which eventually leads to quicker performance.

    • Free Of Schema

    Elasticsearch is also “schema-free,” which means it doesn’t need any kind of data definition and ordinarily indexes dates using defaults unless a specific data type is given.

    To put it simply, Elasticsearch receives JSON files, determines the data type, indexes the data, and makes them searchable.

    Additionally, when an entity with a new attribute is indexed later, the mapping definitions are immediately updated to include it.

    How to Install ElasticSearch

    Install ElasticSearch on UNIX or Linux-based systems.

    1. Ensure Java is installed on your system; install openJDK or OracleJDK.
    2. Run the following commands in order:

    Commands 1-3 compare the SHA of the downloaded .tar.gz file archive the checksum published, which will display:


    Commands 4&5 are a directory known as $ES_HOME.

    Install ElasticSearch archive for MacOS

    Run the following commands in order:

    1. wget%20https:/artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.2-darwin-x86_64.tar.gz
    2. wget%20https:/artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.2-darwin-x86_64.tar.gz.sha512
    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

    Commands 1-3 compare the SHA of the downloaded .tar.gz file archive the checksum published, which will display:


    Commands 4&5 are a directory known as $ES_HOME.

    Download ElasticSearch for Windows with .zip.

    ElasticSearch can be activated on Windows by using the .zip archive. This comes alongside a command that sets up ElasticSearch to run as a service.

    1. You will have to download the .xip archive for your ElasticSearch v7.15.2 from this website:


    1. Now you will unzip the file using WinRar, 7Zip, or any unzip tool that you find suitable. This will now create a new folder which will be named ElasticSearch- 7.15.2 that can be referred to as %ES_HOME%.
    2. Enable the creation of the system indices. ElasticSearch, by default is configured to automatically allow index creation without additional steps. However, if you have disabled the automatic index creation, you must configure the action.auto_create_index in the elasticsearch.yml and allow the commercial features to install the following indices:

    action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*.


    1. Now you can run the command line as follows on your command prompt: \bin\elasticsearch.bat.

    If your ElasticSearch Keystore is password-protected, it will be required that you enter the key store’s password that you set. As a default, ElasticSearch prints the logs to the console command of STDOUT and also to <clustername>.log within the logs directory.

    ElasticSearch can log some data while the search engine boots up. After it is established, it can continue to be used in the foreground and will not log any data unless an event worth recording occurs. While ElasticSearch is active, you can interact with the HTTP interface which is by default on port 9200. In order to terminate ElasticSearch, Press Ctrl-C on your keyboard.

    1. Now you need to configure ElasticSearch on the command line.ElasticSearch will load its configuration from the %ES_HOME%\config\elasticsearch.yml file by default. Any setting that can be specified config will subsequently also be specified on the command line, using a syntax of –E. For example, .\bin\elasticsearch.bat -Ecluster.name=my_cluster -Enode.name=node_1.
    2. Now check if ElasticSearch is running by sending an HTTP request to the 9200 port on localhost:

    GET/ which will return a response defining the name, class and cluster, etc.

    1. Install ElasticSearch as a service on Windows. ElasticSearch can now be installed as a service that can run in the background and start automatically at boot time independent of any user interaction. This can be achieved by accessing the ElasticSearch-service.bat script in the bun\ folder. This can install, remove, configure or manage the services, all from the command-line interface.

    In case you find activating the services challenging, which they are for people who do not have extensive knowledge in development, you can Magento support services.

    Magento Migration

    Set up ElasticSearch

    Now ElasticSearch is installed on your system. You must now set up and configure ElasticSearch. Elastic search already configure the system based on the default settings. In order to configure with Magento you can follow the steps:

    • Log into your Magento store account on Admin and the administrator.
    • Click on stores, then setting, then configuration, catalog, and select catalog search.
    • Now from the search engine list, select your installed ElasticSearch version.

    In case you have configured the setting from your end, these configuration options will help you configure Magento 2.

    Elasticsearch Server Hostname: Enter the IP address of your machine that is responsible for running ElasticSearch.

    Elasticsearch Server Port: Input the ElasticSearch web server’s proxy port. The default port is 9200.

    ElasticSearch Index Prefix: Enter the index prefix for ElasticSearch.In case you are using a single instance of ElasticSearch for more than one Magento store, you will have to specify a unique prefix for each installation.

    Enable ElasticSearch HTTP Auth: You should only click yes if you had enabled the authentication for your ElasticSearch server. You will provide your username and password in the fields.

    Test Your Search.

    Now you must test your connection by clicking the test connection button. If you see “Successful! Test again?” you can then proceed to configure Apache and ElasticSearch if you wish.

    If the feedback is “Connection failed! Try again?” Then you can try the following to set your connection correctly.

    • Ensure that the ElasticSearch server is running on the back-end by running the command \bin\elasticsearch.bat on the backend.
    • In case the ElasticSearch server is not on the host from Magento, you will log in to the Magento server and then ping the ElasticSearch host. This will resolve the network connectivity issues and then you should click on test the connection
    • Scrutinize the command prompt, where you had initiated the ElasticSearch for stack traces and exceptions. Resolve this before you continue by making sure that you had initiated ElasticSearch as a user who has access to root
    • Check whether the UNIX firewall and SELinux are both disabled. Then also examine if the setup rules successfully allow ElasticSearch to communicate with Magento.
    • Recheck the value of the ElasticSearch Server Hostname and make sure it is valid. Ensure that the server is available, you could also try your server’s IP (Internet Protocol) address.

    Magento development

    What are the ElasticSearch Extra Features?

    ElasticSearch provides extensively exclusive features. The reason why ElasticSearch is the number one

    Data storage is flexible:

    • ElasticSearch supports a number of customized data types such as text, vectors, histograms, numbers, shapes, structured and unstructured data, flattened fields, and date/time series. This provides users to run different actions on relevant data to examine, store, and use the data as per their requirements. The constraint of specific or primitive data types is removed.
    • The storage of unstructured documents is also an extra feature. Now, it is not necessary that structured data is analyzed or ingested. This design allows design patterns to be simple
    • Unstructured documents can also be stored as it is not necessary that only structured data is ingested or analyzed. This design allows the design to be simple and also makes the search engine to be an effective document store, even after not being a NoSQL database.
    • ElasticSearch allows the use of a unique data structure, namely the inverted index. This feature allows for very quick full-text searches due to dynamic indexes.
    • Data can also be stored in vertical column forms. Values of documents are saved on on-disk data structures in ElasticSearch. These make this data access pattern possible. This is the reason ElasticSearch is able to excel at analyzing metrics and accessing time series.

    Making sure the data is safe internally and secure from external threats in real-time:

    • The Elastic stack derives policies for its work environments that dictate that disk-level encryption be configured on all the host machines. Additionally, snapshot targets ensure that the data stored is encrypted and is inaccessible from unprivileged users.
    • ElasticSearch includes API security, for on-field and document levels. This means some users are unable to have access to restricted documents and fields.

    Manage the data efficiently:

    • Clustered indices are used. These are a collection on or more nodes that altogether hold data and provide indexing and searching functionalities across servers in collections called clusters. This architecture allows data to be scaled horizontally. REST APIs and user interfaces allow a user to manage their cluster architecture.
    • If you want to preserve your memory by half, you can take source-only data snapshots. They contain stored fields and index metadata and omit indexes and are not searchable when they are restored.
    • A backup snapshot of your data cluster is taken which can then be stored on an external repository on another shared file. This makes a back for the data in another location in case something goes wrong at another place.
    • Historical data is generally kept for data analysis but due to the financial costs, it is not preferred. So the index management system reduces computation time by providing the rollup indices feature. This provides a summary and subsequently stores that data so that it can be utilized for analysis at an exponentially lower cost as compared to storage for raw data.

    Data is enhanced for internal use.

    • The data analyzer feature allows the text entered to be converted into a different form for searching purposes. To achieve this, tokenizers are used. The tokenizers break up a stream of characters into separate word tokens that are used to record the order of the terms of their relative positions/.
    • In case of errors in a string, character filters can pre-process the stream and transform the stream by adding, deleting, or changing the characters for custom analyzers.

    Examine words and provide task migration.

    • ElasticSearch provides features such as auto-complete the search word. This navigational feature guides users to relevant and precise results that they were about to enter But the search engine can predict what they require before users the word completely. This feature is provided as a word completion suggestion.
    • If the user searches for data that have grammatical or spelling errors, our ElasticSearch engine can detect and fix this shortfall. The provided suggested text is analyzed before terms are suggested. The suggested terms are provided per the analyzed suggested text token.
    • A phrase suggester feature is also present. This adds the did-you-mean functionality to our search by providing additional logic alongside for and/or/if. Also, the term suggesters help us select correct phrases. This allows the search engine to make efficient decisions about which tokens to store on the basis of frequencies and occurrences in other words.

    Magento 2 ElasticSearch integration can help your store grow by boosting sales. It is preferable to make use of e-commerce solutions companies as the Magento 2 pricing packages they provide cover expenses of the integration alongside Magento support services.

    What is the Flexibility of ElasticSearch Ultimate?

    The flexibility of ElasticSearch is one of the most resilient features provided by ElasticSearch. Flexibility means that the search engine can perform with the changing requirements. It offers scalability and resiliency for the users. It is able to provide:

    • High availability for data as it clusters the nodes together. These then hold the data and provide searching and indexing capabilities across the nodes.
    • Recoverability to the data by replacing the deleted storage with a replica. This ensures that if the user deleted the data accidentally, he can recover the data.
    • The search engine is smart enough to be aware as to which physical location is the data stored on.
    • Cross-data center data replication means that your data is saved at more than one location to access it accordingly.
    • Scalability, if more data requests are being sent then the search engine can increase the performance of the physical hardware that helps manage the huge traffic on the servers.

    Magento integration


    Magento 2 ElasticSearch is a very powerful integration that can help your store grow in terms of consumers. The integration will provide your store with a platform that has the potential to satisfy each and every customer uniquely. This is due to the features provided by Magento 2 ElasticSearch integration such as flexibility in storing and accessing the data, the search engine has security code executing on the backend in real-time that prevents live attacks on the server, and the examination of data in such a way that the user does not feel burdened if he forgets his requirements or makes any errors while searching.

    You should hire professional Magento Development Companies that provide e-commerce solutions. Make sure that they have certified developers and extensive experience. They can even provide packages for Magento 2 pricing that is affordable and includes Magento Support services so that you can make use of these and make your store stand out amongst your competitors.


    Q) What is Magento ElasticSearch? How does it work in Magento 2?

    A) Magento ElasticSearch is the integration of the Magento 2 platform and the ElasaticSearch search engine. This powerful integration allows the users to find what they are looking for at quicker speeds and also ensures that the user finds what they are looking for even if they are unsure of the exact requirements. This powerful integration will increase data manageability and effectively utilize the resources at its disposal.

    With an added layer of protection, the users are able to secure the data from external threats and ensure the data is safe. This integration is best performed by e-commerce solution providers such as Folio3. These expert Magento Development Companies are able to provide solutions to your problems and even ensure that your store maintains or upgrades as per the trends, by providing Magento Support Services.

    Q) How does Magento search work?

    A) The Magento search works by making use of the query. The site re-indexes the buffer and adds the information about the attributes that are involved in the search with respective databases. As the user enters a query, the site breaks it down into elements that are separated from the logical statements such as OR, AND connectives. The site breaks the words down into separate elements.

    For example, the query “Clothes for parties” will be divided into three elements. Then the site will check each element with the unique records it holds for that element and if it encounters products that are related, the product is displayed. This allows the right products to be displayed to the user. To ensure that your Magento e-commerce store can handle complex queries, you can make use of Magento 2 ElasticSearch

    Q) Why is Magento 2 ElasticSearch fast?

    A) ElasticSearch can provide results that are precise and robust. These results are computed by using several techniques such as:

    • Storing the data in clusters which allows data that is closely related to be retrieved in a short amount of time as they lie closer to each other.
    • Using a unique data structure called the inverting index. This is a dynamic index which means it is flexible in nature and can adjust according to the scenarios.
    • Magento 2 ElasticSearch is able to break words into tokens and show the results closest to the entered query after comparing the words in the database.
    • It stores redundant data on quick access, which results in a quick display of the data commonly used. Since it is stored in a place that allows quick access, the system is able to find the data quicker.

    That is why it would be a good idea to use Magento 2 ElasticSearch integration. It will provide the best user experience for your customers.

    Q) Is ElasticSearch free?

    A) ElasticSearch s freeware. It means that you can use the application under the SSPL or Elastic License. Furthermore, additional plugins and extensions are available that can be utilized by users.

    There are some features that can be obtained by paying for the services. ElasticSearch is free so it would be a good choice to activate it as soon as possible. If you cant do it yourself, you can use Magento support services provided by Magento development companies.

    Q) Magento Sphinx Search vs Magento Elasticsearch?

    A) SphinxSearch is an open-source full-text look server designed by considering significance focused on integrational robustness.

    ElasticSearch is a search engine built upon the Apache Lucene library. It gives a fully capable text search engine alongside an HTTP web interface.

    Related Blog:

    What is Magento 2 search criteria builder?


    Folio3, a Software Powerhouse established in 2005, is one of the leading eCommerce solution providers for SMBs and Fortune 500. The Company has expertise in diverse industries such as Animal Care, Retail, Automotive, Food and Agriculture, and Health care. From ecommerce store design and development to full-scale ERP deployment and integration, Folio3 has done it all.