Nowadays, most of us have heard about the word Elasticsearch, but not everyone thoroughly understands – What it is and what does it do? And, how might you benefit from it?

We’ve got an answer for you, right here in this blog. It is comprehensive, yet easy for almost anyone to read. 

What Is Elasticsearch?

Elasticsearch is a powerful open-source database that stores, retrieves, and manages document-oriented and semi-structured data. Like MongoDB, ElasticSearch is also a Document-based NoSQL Data Store. Basically, the Elasticsearch helps to store and map all documents effectively in order to optimize the search and retrieval function. The ease of use, powerful features, and scalability has led to its popularity.

Elasticsearch uses HTTP methods (GET, POST, PUT, DELETE, etc.) in combination with HTTP URI to manipulate the data. The intuitive RESTful approach is both developer-friendly and user-friendly, which is one of the reasons for Elasticsearch’s popularity.

What does it do?

Using the API, we can send data in the form of JSON documents to Elasticsearch, where it automatically stores the original document and adds a searchable reference to the document in the cluster’s index. We can then search and retrieve the document using the Elasticsearch API. 

We can relate Elastic Search with RDBMS as the following

RDBMS Elastic Search
Database Index
Table Type
Row Document

What are the Benefits of Elasticsearch?

  • Elasticsearch performs swift and advanced searches on products in the catalog.
  • Easy Application Development – Provides support for various languages including Java, Python, PHP, JavaScript, etc.
  • High Performance – It processes a large volume of data in parallel, quickly finding the best matches for your queries.
  • Near Real-Time Operations – Reading or writing data usually takes less than a second to complete.
  • Indexing does not impact customers until reindex is completed.
  • Supports stop words and synonyms.
  • Accurate, performant, and scalable.

Why Should We Use Elasticsearch in Magento 2?

In all eCommerce websites, including the ones built on Magento 2, the search is no doubt one of the most pivotal functionalities. An effective search helps shoppers find their needed products on the store with ease, which might result in a better customer experience and stimulated purchases. On the other hand, a poor search tool can slow down the process of looking for the items and even be the reason for high buyer bounce rates.

Therefore, it is essential to enhance the search feature in Magento 2 stores, and applying Elasticsearch is one of the best ways to do that.

How are search requests processed in Magento with Elasticsearch?

Magento Elasticsearch

  • A search request from a user is received by the Magento web server, which then forwards it to the Elasticsearch.
  • The Elasticsearch web server proxies the request to the Elasticsearch server (by default, it listens on port 9200). 

The access to Elasticsearch is further protected by HTTP Basic authentication.

For any type of request to reach Elasticsearch, it must travel over SSL and provide a valid username and password.

  • Elasticsearch processes the search request.
  • With the Elasticsearch web server acting as a secure reverse proxy, communication returns along the same route.

For more information check the following link.

https://devdocs.magento.com/guides/v2.3/config-guide/elasticsearch/es-overview.html click here for detailed information.

How to Install Elasticsearch in Ubuntu OS?

Step 1: Install OpenJDK 8

Verify the Java installation by running the following command which will print the Java version:

The output should look something like this:

java version “1.8.0_201”

Java(TM) SE Runtime Environment (build 1.8.0_201-b09)

Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Step 2: Install Elasticsearch

Now that OpenJDK 8 is installed, run the below commands to add Elasticsearch GPG key by importing it.

Note: GPG is an encryption technique.Gnu Privacy Guard is an implementation of OpenPGP (Open Pretty Good Privacy). 

The command above should provide the output “OK”, which means that the key has been successfully imported and packages from this repository will be considered trusted.

Next, add the Elasticsearch repository to the system.

Note: Change 7.x in the command above with the version you need.

Once the Elasticsearch repository is added and enabled, run the following commands to update apt package list and install Elasticsearch.

Elasticsearch service will not start automatically after the completion of the installation process. To start the service and enable the service, run:

If you’re running a single host server and the clients are connecting from the same server, then no configuration is required. If the clients will be connecting from remote systems, then you need to allow external clients.

To do that, open the elasticsearch.yml configuration file:

Then search for the line that contains network.host, uncomment it, and then change the localhost to: 0.0.0.0

# Set the bind address to a specific IP (IPv4 or IPv6):

#

network.host: localhost

#

# Set a custom port for HTTP:

#

http.port: 9200

#

# For more information, consult the network module documentation.

Save the file and exit

restart elastic search

Note: By default, Elasticsearch listens to the 9200 port for the upcoming HTTP queries

You can verify if the Elasticsearch is running by sending the HTTP request to port 9200 on localhost with the following curl command:

(or)

By opening the http://localhost:9200/ URL in your browser.

You should see something similar to this:

{

“name” : “zdwJeew”,

“cluster_name” : “elasticsearch”,

“cluster_uuid” : “9bLHkEejTUaiJQ-fHbrtyA”,

“version” : {

“number” : “5.6.16”,

“build_hash” : “3a740d1”,

“build_date” : “2019-03-13T15:33:36.565Z”,

“build_snapshot” : false,

“lucene_version” : “6.6.1”

},

“tagline” : “You Know, for Search”

}

Congratulations, at this point you have installed Elasticsearch on your Ubuntu server.

Step 3: How to Configure Elasticsearch within Magento?

At this point, your elastic search engine is ready to process queries/requests. In order to configure elastic search in Magento, perform the following updates.

  1. Log in to the Magento Admin.
  2. Navigate to Stores > Settings > Configuration > Catalog > Catalog > Catalog Search.
  3. Based on the following figure shown from the Search Engine list, select the correct Elasticsearch version.

Ensure the following fields have the valid details:

  • Elasticsearch Server Hostname – Enter the complete qualified hostname or IP address of the machine running Elasticsearch. By default, the value will be localhost.
  • Elasticsearch Server Port – Enter the Elasticsearch web server proxy port. By default, the value will be 9200.
  • Elasticsearch Index Prefix – Enter the Elasticsearch index prefix. If you use a single Elasticsearch instance for more than one Magento installation (Staging and Production environments), you must specify a unique prefix for each installation. By default, the value will be magento2.
  • Enable Elasticsearch HTTP AuthClick Yes, only if you have enabled authentication for your Elasticsearch server. If so, provide the valid username and password in the required fields.

Step 4: Click Test Connection

         You will see either:

         Successful! Test again?

         or

        Connection failed! Test again? 

If you get a ‘connection failed!’ message, make sure the elastic server is available and the given IP Address, Port, Username, Password, and all the other details are valid.

That’s it!  Now your store is ready to provide a rich and smooth search experience to your customers!

Be the first to Know

Subscribe to our blog to get the latest articles directly to your inbox.

READY TO DRIVE SALES?

Ready to drive online revenue

Get In Touch

Leave a Reply

Be the First to Comment!