I heard this term “Elasticsearch” while I was working in a banking project, and it was used as a solution to replace a search engine for our application. Before I started to explore it, the only thing I used to hear was that it is a search engine like google, it has indexes and has the ability to search the data very fast and we can also perform analytics. I couldn’t get my hands dirty on Elastic search since I was not part of that migration project. After quite some, now I got a chance to work and implement whatever I heard back then. The creator of Elasticsearch Shay Bannon built this for searching his wife’s cooking receipies is now among the most widely used technology for most of the problem domains.
Table of Contents
What is Elasticsearch
Elasticsearch is a NoSQL database which was created by Shay Bannon in February 2010. It is licensed under the Apache version 2.0 and is based on Apache Lucene search engine. Elasticsearch was developed using Java programming language. Similar to MongoDB, Elasticsearch is also a document based storage database engine. Apart from searching the data, Elasticsearch allows you to analyze huge amount of data and also retrieve the data within milliseconds. Elasticsearch is a server which accepts JSON requests and returns response in JSON format.
Nowadays Elasticsearch is widely used for storing the application logs.
Common Terminologies
Documents – Document is like a row in relational databases like MySql, Oracle etc. A document can be either a string, number or an entity in JSON format. Similar to a datatype in relational databases, we also have datatypes for the documents we are storing. Each document will have an ID associated with it.
Field – Field is like a column in Relational database.
Index – Index is like a table in Relational database. Index is basically a collections of documents.
Why to use Elastic search?
There are some disadvantages of using relational databases such as slowness when the data increases drastically. Since we have schema in relational databases, we cannot fit in data which does not belong to the database structure. Elasticsearch can be beneficial to your project if you have below requirements.
1) If the data you have does not follow a common structure. That means you can store structured as well as unstructured data.
2) Apart from retrieving the data you can also perform analytics to derive meaningful data or trends which will help grow your business.
3) While you are trying to search some data, Elasticsearch helps to complete the search term which you are writing by assisting you via its auto complete feature.
Usage of Elasticsearch
1) Logging
Most of the organisations today are using ELK stack for their log management. Each component has its own role to play
E – Elastic Search
Elastic search is where the data will be stored
K – Kibana
Kibana is a tool which helps you to view your data in a meaningful way. It is basically a visualization tool which allows you to view your data in graphs, charts and various other formats. These proper visual representation will help you to see plan things or work on area where your business is lagging.
L – Logstash
Logstash is used to ingest data that it gets from multiple sources into Elastic search. Logstash can also can also aggregate and process data.
2) Custom Business applications
One of the use case can be that if our application is dependent on some external entity which is the source of data, and that system charges you per hit/call you make. In that case whatever data we fetch we can store the fetched data in Elastic search. The next time you require the, instead of calling the external system, you can query on Elastic search
3) Analytics
As we saw the example of ELK stack in our 1st point, we can know or learn particular trends in an organisation. For example Netflix can use its Analytics to see which content the audience is searching the most and accordingly it can promote to a larger audience.
Very well articulated for beginner. It depicts real life application of elastic search. Keep writing such blogs. ๐
Thanks Nishant! Glad that you liked the article ๐