Sitemap

How Elasticsearch Works?🧐

4 min readAug 12, 2024

--

Press enter or click to view image in full size

How elastic search works?

1. Data Ingestion

Data Submission: Data is sent to Elasticsearch in JSON format, usually via its REST API or ingestion plugins for various data sources.
Analysis and Parsing: Elasticsearch automatically analyzes and parses the incoming data, identifying text fields, numbers, dates, geolocations, and more to understand its structure and prepare for indexing.

2. Indexing

Inverted Index Creation: Elasticsearch constructs a highly optimized inverted index, mapping words and their locations within documents. This acts like a book’s index, enabling lightning-fast retrieval of relevant information.
Field Analysis: Elasticsearch applies appropriate analyzers to text fields to break down text into tokens (words or phrases) for indexing, considering factors like language, stemming, and synonyms.
Document Storage: Indexed documents are stored in shards, ready for searching.

3. Sharding and Replication

Sharding: Elasticsearch divides indices into smaller units called shards, distributing them across multiple nodes in a cluster. This enables horizontal scaling and parallel processing.
Replication: Copies of shards, called replicas, are created to ensure fault tolerance and boost read performance. If a node fails, replicas take over, ensuring data availability.

4. Querying

Query Submission: Users submit search queries through Elasticsearch’s REST API or a query language like Elasticsearch Query DSL.
Query Parsing: Elasticsearch analyzes the query, identifying keywords, filters, and other search parameters.

5. Search Execution

Inverted Index Lookup: Elasticsearch leverages the inverted index to quickly locate matching documents based on the query terms.
Scoring: Elasticsearch applies scoring algorithms (like TF-IDF) to rank results based on relevance to the query, ensuring the most relevant results appear first.

6. Result Collection and Aggregation

Document Fetching: Elasticsearch retrieves the top-ranked documents from the relevant shards.
Aggregations (Optional): If the query involves aggregations (e.g., counts, averages, groupings), Elasticsearch performs those calculations to summarize and analyze the data.

7. Result Presentation

Get Khushi Malhotra’s stories in your inbox

Join Medium for free to get updates from this writer.

JSON Response: Elasticsearch returns the search results in JSON format, typically containing document information, scores, and any requested aggregations.
Formatting and Display: Applications consuming the results can format and present them to users in user-friendly ways, such as lists, grids, or visualizations.

Elasticsearch and Apache Solr

Press enter or click to view image in full size

Key Differences Between Solr and Elasticsearch

Focus

  • Solr: More focused on traditional search and analytics.
  • Elasticsearch: Excels in real-time search, analytics, and data exploration.

Architecture

  • Solr: Based on Apache Lucene.
  • Elasticsearch: A standalone solution built on Apache Lucene.

Deployment

  • Solr: Often requires more manual configuration and setup.
  • Elasticsearch: Generally easier to deploy and manage.

Scaling

  • Elasticsearch: Designed for horizontal scaling, ideal for large-scale data sets.
  • Solr: Can scale as well, but may require more manual effort.

Analytics Capabilities

  • Elasticsearch: Offers robust analytics features, including aggregations, visualizations, and machine learning capabilities.
  • Solr: Has some analytics features, but they aren’t as comprehensive.

Ecosystem

  • Elasticsearch: Has a larger and more active community, offering a wider range of plugins, integrations, and support resources.

Specific Advantages

Solr

  • Strong focus on traditional search and analytics.
  • Handles rich text formats (RTF) effectively.
  • Can be more performant for specific use cases.
  • Offers a more granular level of control over configuration.

Elasticsearch

  • Excels in real-time search and data exploration.
  • Easier to deploy and manage.
  • Better suited for large-scale data sets.
  • More comprehensive analytics features.
  • Larger and more active community.

Use Cases

Solr

  • E-commerce search
  • Content management systems
  • Enterprise search
  • Library catalogs

Elasticsearch

  • Log analysis
  • Real-time monitoring
  • Application performance monitoring
  • Security analytics
  • Fraud detection

Choosing the Right Tool

  • Prioritize Solr if you need a highly customizable search solution with a strong focus on traditional search and analytics.
  • Opt for Elasticsearch if you require real-time search, analytics, scalability, and comprehensive data exploration capabilities.

Which companies uses elastic search? 🫠

Press enter or click to view image in full size

Tech

  • Netflix: Powers their search and recommendation algorithms.
  • Uber: Enables efficient location-based search for drivers and riders.
  • Shopify: Supports product search and analytics for online stores.
  • Udemy: Drives course search and discovery for learners.
  • GitHub: Powers code search and analysis functionality.

E-commerce

  • eBay: Drives product search and discovery for millions of users.
  • Staples: Enables efficient product filtering and search on their website.
  • Magento: Provides search functionality for online stores built on the platform.

Media and Entertainment

  • The Guardian: Powers news search and content discovery.
  • New York Times: Enhances article search and analysis capabilities.
  • Spotify: Supports music search and recommendation algorithms.

Finally the End of Elasticsearch series. 😉

--

--

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?☺️