Sitemap

Elasticsearch

7 min readAug 12, 2024

--

Unleashing the Power of Search
Presented by:- KHUSHI MALHOTRA

What is Elasticsearch?
A distributed, open-source search engine built on top of Apache Lucene

  • Highly scalable and fault-tolerant
  • Capable of indexing and searching large volumes of data in real-time

CONFUSED😕 Let me Explain my child.🧒

Imagine you have a massive library, but instead of books on dusty shelves, you have all the information stored digitally on computers. Now, finding a specific book in this library would be a huge task, right? That’s where Elasticsearch comes in!

Think of Elasticsearch as a super-powered librarian who helps you find the information you need quickly and easily. It’s like a search engine for your own data, but much more powerful and flexible.

Here’s how it works in simpler terms:

Store your information: You give Elasticsearch all your data, like articles, emails, social media posts, or even sensor readings from machines. Elasticsearch organizes it all neatly, making it searchable.
Ask your questions: Instead of browsing through everything, you tell Elasticsearch what you’re looking for. You can ask specific questions like “Find all emails from Khushi about the meeting on Monday” or “Show me articles about AI that were published this month.”
Get instant answers: Elasticsearch uses its special search powers to scan through all your data and find exactly what you need. It’s like having a super-fast librarian who knows exactly where every book is and can bring it to you in a flash.

Elasticsearch is a real-time distributed and open-source full-text search and analytics engine.
Elasticsearch is an Apache Lucene-based search server.

Apache Lucene? Inverted Index??😕 Abb yeh khan se aagaya?😂 Mein battati huin…☺

Press enter or click to view image in full size

Apache Lucene

Imagine you have a large collection of e-books in various formats (PDF, EPUB, etc.):

Indexing: Lucene would use its analyzers to process each e-book Extracting text content Breaking it down into individual words and phrases (tokens)
Creating an inverted index that maps these tokens to their locations within each book Storing metadata like title, author, and file format.
Searching: When a user searches for “artificial intelligence,” Lucene would:

Quickly scan the inverted index to find books containing those terms Calculate relevance scores based on factors like term frequency, proximity, and field weighting.
Ranking: Lucene would present the most relevant books first, potentially highlighting matching terms within excerpts or summaries.

How Apache Lucene helps Elasticsearch?

Lucene’s Foundational Role:

Core Search Engine: Lucene forms the underlying engine that powers Elasticsearch’s search capabilities. It provides essential features like:
- Indexing documents
- Analyzing text
- Building inverted indexes
- Searching for and ranking relevant results
- Highlighting matching terms

Elasticsearch’s Value-Added Layers

Get Khushi Malhotra’s stories in your inbox

Join Medium for free to get updates from this writer.

Distributed Architecture: Elasticsearch extends Lucene’s capabilities to handle massive datasets across multiple servers, enabling horizontal scaling and fault tolerance.

Advanced Features: Elasticsearch adds functionalities beyond Lucene’s core, including:
- Aggregations for data summarization and analysis
- Filtering to narrow down results based on specific criteria
- Autocomplete for suggesting queries as users type
- Near real-time search for near-instantaneous results
- Geospatial search for location-based queries

Key Benefits of Lucene for Elasticsearch:

Proven Search Algorithms: Elasticsearch inherits Lucene’s well-tested and efficient search algorithms, ensuring high-quality search results.
High-Performance Indexing and Search: Lucene’s inverted index structure and optimization techniques enable fast indexing and retrieval of documents.
Flexible Text Analysis: Lucene’s customizable analyzers allow Elasticsearch to handle diverse text data in different languages and domains.
Scalability and Reliability: Elasticsearch leverages Lucene’s strengths to build a distributed search platform that can scale horizontally and tolerate failures.
Rich Feature Set: Elasticsearch builds upon Lucene’s core to offer a broader range of features, making it a versatile tool for various search and analytics use cases.

Inverted Index

Press enter or click to view image in full size

An Inverted Index is a data structure used in information retrieval systems to efficiently retrieve documents or web pages containing a specific term or set of terms. In an inverted index, the index is organized by terms (words), and each term points to a list of documents or web pages that contain that term.

Inverted indexes are widely used in search engines, database systems, and other applications where efficient text search is required. They are especially useful for large collections of documents, where searching through all the documents would be prohibitively slow.

An inverted index is an index data structure storing a mapping from content, such as words or numbers, to its locations in a document or a set of documents.
The term “inverted index” refers to the structure and organization of an index in a way that is the opposite (or inverted) from the way data is typically stored.

Elastic search is used for SINGLE PAGE APPLICATION.
Single-page applications often deal with large amounts of dynamic data displayed on a single page. Elasticsearch excels at indexing and searching this data, allowing users to find specific information quickly and easily, even through complex queries. This can enhance user experience significantly and make your SPA feel more responsive.
Real-time updates: With features like “refresh” and “scroll”, Elasticsearch can handle data updates in real-time, meaning changes in your SPA’s data are reflected in search results instantly. This keeps your users informed and avoids the need for page refreshes.
Scalability: As your SPA grows and user traffic increases, Elasticsearch can scale horizontally to handle increased load. This means your search functionality and analytics remain performant even with large datasets and high user numbers.

KEY FEATURES
1. Full-text search (FTS) is a technique for searching text-based content for specific words or phrases
2. Real-time indexing refers to the process of adding new data to an index as it becomes available, with minimal latency. In the context of search engines and databases like Elasticsearch, real-time indexing is crucial for providing up-to-date and accurate search results or data analysis.
3. Horizontal scaling also known as scaling out, is an approach to increase the capacity or performance of a system by adding more hardware or instances to the existing infrastructure.
4. Fault Tolerance is crucial for ensuring the availability and reliability of search and indexing services, especially in distributed and large-scale environments.
5. Node-Level Fault Tolerance Elasticsearch clusters consist of multiple nodes, and the loss of a single node should not lead to a significant disruption. The system automatically redistributes shards and adjusts the cluster state when nodes join or leave.

Use cases of Elasticsearch

Press enter or click to view image in full size

1. Web Search:

Indexing: Crawls website pages, extracts text and data, and builds an inverted index for rapid searching.
Full-text search: Users can search for specific keywords, phrases, or even synonyms across large volumes of content.
Relevance ranking: Results are ranked based on factors like keyword frequency, page authority, and user history.
Facets and filtering: Users can refine their search using filters like category, date, or author.
Real-time updates: Changes to website content are reflected in search results almost instantly.
Examples: Wikipedia, Stack Overflow, GitHub, news websites.

2. E-commerce Search:

Product Indexing: Indexes product details like title, description, specifications, and tags.
Autocomplete and suggestions: As users type, suggests relevant products based on their partial query.
Faceted search: Users can filter products by price, brand, color, size, and other attributes.
Personalized recommendations: Recommends products based on user purchase history, browsing behavior, and similar user preferences.
Geolocation search: Search for products available in specific locations.
Examples: Amazon, eBay, Alibaba, any e-commerce platform with a large product catalog.

3. Security Analytics:

Log ingestion and analysis: Collects and analyzes security logs from various sources like firewalls, network devices, and applications.
Threat detection: Identifies potential security threats by analyzing logs for anomalous patterns and suspicious activity.
Compliance reporting: Generates reports to comply with security regulations and audit requirements.
Real-time monitoring: Provides real-time insights into security threats and alerts security teams of potential breaches.
User activity monitoring: Tracks user activity and identifies suspicious behavior to prevent fraud and data breaches.
Examples: SIEM (Security Information and Event Management) platforms, security operations centers, compliance monitoring systems.

4. Social Media Analytics:

Social media data ingestion: Collects data from social media platforms like tweets, posts, and comments.
Sentiment analysis: Analyzes the sentiment of social media content to understand public opinion and brand perception.
Trend tracking: Identifies trending topics and hashtags to stay ahead of the curve.
Influence analysis: Identifies key influencers and analyzes their reach and engagement.
Customer feedback analysis: Analyzes customer feedback on social media to improve products and services.
Examples: Marketing research, brand monitoring tools, social media listening platforms, customer service teams.

Finally…😮‍💨🫨 Baki topics next blog mein…😉

For more in-depth discussions on Elasticsearch, be sure to check out my upcoming blog post. Node, Cluster, Document, Shards, Index and Replicas?🫨

--

--

Khushi Malhotra
Khushi Malhotra

Written by Khushi Malhotra

DevOps engineer by day, knowledge sharer by passion. I love learning, but even more, I love spreading those insights—because why keep the fun to myself?☺️