Open In App

Elasticsearch Search Engine | An introduction

Elasticsearch is a full-text search and analytics engine based on Apache Lucene. Elasticsearch makes it easier to perform data aggregation operations on data from multiple sources and to perform unstructured queries such as Fuzzy Searches on the stored data. It stores data in a document-like format, similar to how MongoDB does it. Data is serialized in JSON format. This adds a Non-relational nature to it and thus, it can also be used as a NoSQL/Non-relational database. A typical Elasticsearch document would look like:

{
  "first_name": "Divij",
  "last_name":"Sehgal",
  "email":"xyz@gmail.com",
  "dob":"04-11-1995",
  "city":"Mumbai",
  "state":"Maharashtra",
  "country":"India",
  "occupation":"Software Engineer",
}

Where do we use Elasticsearch?



Elasticsearch is a good fit for –

Elasticsearch Concepts Elasticsearch works on a concept known as inverse indexing. This concept comes from the Lucene library(Remember Apache Lucene from above). This index is similar to terms present at the back of a book, that show the pages on which each important term in the book may be present or discussed. The inverted index makes it easier to resolve queries to specific documents they could be related to, based on the keywords present in the query, and speeds up a document retrieval process by limiting the search space of documents to be considered for that query. Let’s take the following three Game of Thrones dialogues:



  1. “Winter is coming.”
  2. “A mind needs books as a sword needs a whetstone, if it is to keep its edge.”
  3. “Every flight begins with a fall.”
  4. “Words can accomplish what swords cannot.”

 Consider each of these dialogues as a single document, i.e, each document has a structure like:

{
    "dialogue": "....."
}

 After some simple text processing: After lowercasing the text and removing punctuations, we can construct the “inverted index” as follows:

Term Frequency Documents
a 4 2, 3
accomplish 1 4
as 1 2
begins 1 3
books 1 2
can 1 4
cannot 1 4
coming 1 1
edge 1 2
every 1 3
fall 1 3
flight 1 3
if 1 2
is 2 1, 2
it 1 2
its 1 2
keep 1 3
mind 1 2
needs 1 2
sword 1 2
swords 1 3
to 1 2
what 1 3
whetstone 1 2
winter 1 1
with 1 3
words 1 4

Few common terms associated with Elasticsearch are as follows:

Article Tags :