In all of the e-commerce websites including the ones built on Magento 2, the search is no doubt one of the most pivotal functionalities. An effective search will help the shoppers to find their needed products on the store at ease, which might result in better customer experience and stimulated purchases. On the other hand, the poor search tool can slow down the process of looking for the items and even be the reason for the high buyers’ bounce rates. Magento Elasticsearch is one way around this problem
Why Should We Use Elasticsearch In Magento 2?
Not everyone thoroughly understands what Elasticsearch is. Elasticsearch is a powerful open-source search and analytics engine using Apache Lucene. It is able to handle a large number of use cases, support multiple tenancies and full-text search on the HTTP web interface. In simple words, the Elasticsearch helps to store and map all documents effectively in order to optimize the search and retrieval function. In the scope of this blog post, we will discuss specifically Magento Elasticsearch.
Magento only integrates Elasticsearch in Magento Open Source 2.3.0 and Magento Commerce edition. For Magento Open Source 2.2.x, you need to install a proper module to have Elasticsearch’s powerful features. Now, there are several options when it comes to Magento 2 Elasticsearch module, both free and paid.
Before actually getting into the setup procedure, fair warning, this is not for beginners. In fact, though Magento Elasticsearch does have its benefits, it is better to go for an alternative that is a bit more ready-made and easily customizable.
Take a look at ExpertRec’s Magento search plugin and Magento 2 search plugin. This will add a search to your store that gives all modern perks like voice search, auto-complete, live suggestions and much more. Another advantage here is the easy setup and configuration options that Elasticsearch will not give.
If the plugin method does not work out as expected then try the crawl based method.
- Navigate to https://cse.expertrec.com/newuser?platform=cse and signup with your Google ID.
- Enter your website’s URL when prompted. You can select a server location near you and add the URL of your sitemap if you wish to. These will be auto-detected otherwise.
- You can play around with the settings and customize the UI as the crawl runs. Once it is complete, you can check out a fully functional demo before taking the search to your website.
- You can take the search to your website with little to no effort. All you need to do is to paste the code snippet available on the dashboard on your website.
ExpertRec comes with more customization options that you can explore. You can read this article to find a more detailed guide on the installation and configuration.
Configuring Magento Elasticsearch
- Log in to your Magento server as a user with root privileges.
- CentOS: Install Elasticsearch 6.x using the Elasticsearch RPM documentation
- Ubuntu: Install Elasticsearch 6.x using the Elasticsearch Ubuntu documentation
- Optionally, configure Elasticsearch as needed.
- If not already running, start Elasticsearch:
sudo service elasticsearch start
- Verify that Elasticsearch is working by entering the following command on the server on which it is running:
curl -XGET '<host>:9200/_cat/health?v&pretty'
To configure Magento to use Elasticsearch:
- Log in to the Magento Admin as an administrator.
- Click Stores > Settings > Configuration > Catalog > Catalog > Catalog Search.
- From the Search Engine list, select the correct Elasticsearch version as the following figure shows. (The Elasticsearch 5.0+/6.0+ options are not available for Magento 2.1.)
- Click Test Connection.
To refresh the cache using the Admin:
- In the Admin, click System > Cache Management.
- Select the checkbox next to Page Cache.
- From the Actions list in the upper right, click Refresh.