Elasticsearch
What is it?
Elasticsearch is a search and analytics engine that stores data and lets you search huge amounts of text very fast.
Explain like I'm 5
Why was it created?
Searching large text with a normal database is slow. Elasticsearch was built to make full-text search and analytics fast and scalable.
Where is it used?
- Site and product search
- Log and event analytics
- Observability dashboards
- Autocomplete and suggestions
Why should developers care?
It powers search bars, logs, and dashboards in countless products, so backend and data engineers commonly work with it.
How does it work?
Documents are stored and broken into an inverted index that maps words to the documents containing them. Searches consult this index, and data is spread across shards for scale.
Real-world example
An online store uses Elasticsearch so a search for 'red running shoes' returns ranked, relevant results instantly across millions of products.
Common use cases
- Full-text search
- Log aggregation and analysis
- Real-time analytics
- Autocomplete
Advantages
- Very fast full-text search
- Scales horizontally
- Powerful querying and aggregations
- Near real-time results
Disadvantages
- Resource-hungry
- Not a primary source-of-truth database
- Operationally complex at scale
- Eventual consistency
When should you use it?
When you need fast text search or analytics over large or growing data.
When should you avoid it?
As your main transactional database — pair it with one instead.
Alternatives
Related terms
Interview questions
Beginner
- What is Elasticsearch used for?
- What is full-text search?
Intermediate
- What is an inverted index?
- What is a shard?
Senior
- How do you keep Elasticsearch in sync with a primary database?
- How would you tune relevance ranking?
Common misconceptions
- "Elasticsearch is a database replacement" — it's usually a search layer beside a primary database, not the source of truth.
- "It's instantly consistent" — indexing is near real-time, not immediate.
Fun facts
- It's commonly paired with log and dashboard tools as part of a search-and-analytics stack.
- An inverted index is the same idea as the index in the back of a book.
Timeline
- 2010 — First released
Learning resources
Quick summary
Elasticsearch is a fast, scalable search and analytics engine that uses an inverted index to query large text and log data quickly.
Cheat sheet
- Search and analytics engine
- Inverted index for fast text search
- Scales via shards
- Pair with a primary database