Elasticsearch interviews test whether you can explain how search works inside, and whether you can keep a cluster fast and healthy. This guide gives you 47 Elasticsearch interview questions and answers, from basics to scenario questions, for freshers and experienced engineers.
Every answer begins with a short, direct response you can say aloud, followed by a table or a request you can try in Kibana. The page reflects current Elasticsearch: one primary shard by default, BM25 relevance, a bundled JDK, no mapping types and vector search for AI applications.
The guide has seven parts: 9 on Elasticsearch basics, 8 on mappings and analysis, 6 on queries and aggregations, 10 on architecture and internals, 4 on vector and semantic search, 4 on the Elastic Stack and comparisons and 6 scenario questions. Use the contents list to jump to your level.
| Section | Questions |
|---|---|
| Elasticsearch Basics (Freshers) | Q1 to Q9 |
| Mappings, Analysis and Text Search (Intermediate) | Q10 to Q17 |
| Queries, Aggregations and Pagination (Intermediate) | Q18 to Q23 |
| Architecture and Internals (Experienced) | Q24 to Q33 |
| Vector and Semantic Search (Current Features) | Q34 to Q37 |
| Elastic Stack and Comparisons (All Levels) | Q38 to Q41 |
| Scenario Questions (Experienced) | Q42 to Q47 |
Start with what Elasticsearch is, how data is organised, and why search is fast. These answers come up in almost every interview.
Elasticsearch is a distributed search and analytics engine built on Apache Lucene. It stores JSON documents, indexes every field, and returns results in near real time. Common uses are website and application search, log and metrics analysis, security analytics, and, in current versions, vector and semantic search for AI applications.
An index is a collection of documents that share a similar structure, like a table in a database. A document is one JSON record, like a row. A field is a key inside a document, like a column. Elasticsearch has no schema requirement up front, but it keeps a mapping that records field types.
| Elasticsearch | Relational database | Note |
|---|---|---|
| Index | Table | Holds documents of a similar shape |
| Document | Row | A JSON object with a unique ID |
| Field | Column | Each field has a type in the mapping |
| Mapping | Schema | Can be dynamic or explicit |
An inverted index maps each term to the list of documents that contain it, the reverse of a normal index that maps a document to its words. To search for a word, Elasticsearch looks up the term and gets the matching documents at once, which makes full text search fast, even across millions of documents.
Lucene builds one inverted index for each text field in each shard segment.
An index is split into primary shards, and each shard is a self contained Lucene index that can live on any node. This spreads data and work across the cluster. A replica is a copy of a primary shard on a different node, which gives fault tolerance and extra read capacity. A replica never sits on the same node as its primary.
What the interviewer is listening for: You explain both purposes of replicas, which are failover and read throughput.
Since Elasticsearch 7.0, a new index gets one primary shard and one replica by default. Earlier versions used five primary shards, which led to many small shards. The primary shard count is fixed when the index is created, though you can use the split or shrink APIs, while the replica count can change at any time.
What the interviewer is listening for: You know that the old default of five shards is gone and that primary shard count cannot simply be edited.
A node is one running Elasticsearch instance, and a cluster is a group of nodes that share the same cluster name and work together. Nodes have roles, such as master eligible, data, ingest and coordinating. Larger clusters use dedicated master nodes, and tiered data nodes such as hot, warm and cold.
No. Packages of Elasticsearch ship with a bundled JDK, and that is the supported and recommended way to run it. You can point it to your own JDK with ES_JAVA_HOME, but only for supported versions. You do not need to install Java first, which is a common mistake in old tutorials.
A new document is not searchable the instant it is indexed. It becomes visible after the next refresh, which happens every second by default on an index that is being searched. The data is safe earlier, because writes also go to the translog. So search is near real time, with a delay of about one second.
Elasticsearch has a REST API over HTTP and JSON. Use PUT or POST to index a document, GET to read it, and DELETE to remove it. There are no mapping types in current versions, so the path uses the index name and the document ID, with the underscore doc endpoint.
This is where search quality is decided. Know how text is broken into terms, and how field types change the result.
A text field is analysed, meaning it is split into terms and lowercased, so it suits full text search. A keyword field is stored as one exact value, so it suits filtering, sorting and aggregations, for example on an ID, a status or a country code. Use a multi field to have both.
Search the name field for full text, and use name.raw to sort or aggregate.
An analyzer turns text into terms, both when indexing and when searching. It has three parts in order: character filters that clean the text, one tokenizer that splits it into tokens, and token filters that change the tokens, such as lowercasing, removing stop words or stemming. The standard analyzer is the default.
| Stage | Job | Example |
|---|---|---|
| Character filter | Clean the raw text | Strip HTML tags |
| Tokenizer | Split into tokens | Break on spaces and punctuation |
| Token filter | Modify tokens | Lowercase, stem, remove stop words |
Use the analyze API with an analyzer name and a sample text. It returns the tokens that would be indexed. This is the fastest way to debug why a search did or did not match, since a mismatch usually comes from a different analyzer at index time and at search time.
The standard analyzer returns three tokens: rubber, insulating and mats, all in lowercase.
With dynamic mapping, Elasticsearch guesses a field type from the first value it sees, which is quick but can guess wrongly, for example a text field where you wanted a keyword or a date. With explicit mapping you define the types yourself. Use explicit mapping in production, and set dynamic to strict for sensitive indices.
No. A mapping for an existing field cannot be changed, because the data is already indexed under that type. Create a new index with the correct mapping, then copy the data over with the reindex API and switch an alias to the new index. Aliases let applications keep the same name.
A mapping explosion happens when dynamic mapping creates too many fields, for example from user supplied keys, which bloats the cluster state and slows the cluster. Prevent it by using explicit mappings, turning dynamic off or to strict, and relying on the index total fields limit, which defaults to 1000. A flattened field type can hold arbitrary keys.
Elasticsearch scores each match with BM25, the default relevance algorithm since version 5.0. BM25 rewards terms that are frequent in the document but rare across the index, and it limits the benefit of repeated words and long documents. You can adjust ranking with boosts, function scores and, for AI search, a combined ranking of text and vector results.
What the interviewer is listening for: You say BM25 is the default, and you can explain term frequency and inverse document frequency in plain words.
A match query analyses the query text and finds documents containing any of the terms. A match_phrase query needs the terms to appear together in order. A term query does not analyse the input and looks for an exact value, so it is meant for keyword, number and date fields, not analysed text.
| Query | Analyses input? | Best for |
|---|---|---|
match |
Yes | Full text search on a text field |
match_phrase |
Yes | Words in an exact order |
term |
No | Exact value on a keyword, number or date |
Interviewers often ask you to write a query on paper. Practise the bool query until it feels natural.
A bool query combines clauses. Must clauses have to match and contribute to the score. Filter clauses have to match but do not affect the score, and they are cached. Should clauses are optional and raise the score. Must_not clauses exclude documents. Put exact conditions in filter for speed.
The old filtered query was removed long ago. A bool query with a filter clause replaces it.
In query context, Elasticsearch asks how well a document matches and calculates a relevance score. In filter context, it asks only whether the document matches, with a yes or no answer and no score. Filters are faster, and Elasticsearch can cache them, so use them for exact conditions.
Aggregations compute summaries over the matching documents. Bucket aggregations group documents, for example by category or by date range. Metric aggregations calculate values such as average, sum or maximum. You can nest metrics inside buckets, which gives results like average price per category. Aggregations use doc values on keyword and numeric fields.
The from and size parameters work for shallow pages but are limited to 10,000 hits by default. For deep paging, use search_after with a stable sort, ideally inside a point in time, which gives a consistent view. The scroll API is no longer recommended for deep pagination in user facing searches.
| Method | Use for | Limit |
|---|---|---|
from and size |
Shallow pages in a user interface | 10,000 hits by default |
search_after with point in time |
Deep or live pagination | Needs a stable sort |
scroll |
Older bulk export code | Not recommended for new work |
A fuzzy query matches terms within a set edit distance, so it tolerates spelling mistakes. A prefix query matches terms that start with given letters, and a wildcard query matches patterns. Leading wildcards are slow because they scan many terms. For search as you type, use the completion suggester or the search as you type field.
ES|QL is the Elasticsearch piped query language. You write a source, then chain commands with the pipe sign to filter, transform and aggregate, much like a shell or SQL. It is executed on the cluster and is suited to analytics and exploration. Recent versions added joins with a lookup index.
Experienced candidates are expected to explain what happens inside a shard and how the cluster stays healthy.
The request reaches a coordinating node, which hashes the document ID to pick a primary shard. The primary writes the document to an in memory buffer and the translog, then forwards it to the replicas. When all in sync copies confirm, the client gets a response. A refresh later makes it searchable in a new segment.
A shard is made of immutable segments. A refresh writes the memory buffer to a new segment so it can be searched. A flush commits segments to disk and clears the translog. A merge combines small segments into larger ones in the background and removes deleted documents. Updates are a delete plus a new index operation.
| Operation | What it does | Effect |
|---|---|---|
| Refresh | Makes recent writes searchable | Default every 1 second |
| Flush | Commits to disk, clears the translog | Durability and recovery speed |
| Merge | Combines segments | Fewer files, reclaims deleted space |
The translog is a write ahead log kept for each shard. Every operation is recorded in it before it is acknowledged, so if a node crashes before the data is flushed to disk, Elasticsearch replays the translog on restart. It gives durability between refreshes and flushes.
Green means all primary and replica shards are assigned. Yellow means all primaries are assigned but some replicas are not, so data is safe but redundancy is reduced. Red means at least one primary shard is not assigned, so some data is unavailable. A single node cluster with replicas set to one stays yellow.
| Colour | Meaning | Typical cause |
|---|---|---|
| Green | All shards assigned | Healthy |
| Yellow | Replicas missing | Node down or single node cluster |
| Red | A primary is missing | Node loss with no copy, or disk full |
Master eligible nodes elect a master using a quorum based voting process, which has been automatic since Elasticsearch 7. The cluster manages its own voting configuration, so you no longer set minimum master nodes by hand. Keep an odd number of master eligible nodes, usually three, so a majority always exists.
What the interviewer is listening for: You mention quorum, an odd number of masters and the removal of the old manual setting.
A common guide is to keep shards between 10 and 50 gigabytes, and to avoid thousands of tiny shards, since each shard costs memory. Give the heap at most half of the machine memory, and keep it below about 31 gigabytes so compressed object pointers stay on. The rest of the memory is used by the file system cache.
Index lifecycle management, or ILM, automates the life of time series indices through phases: hot, warm, cold, frozen and delete, based on age or size. A data stream is an append only series of backing indices that hides rollover from the application. Together they handle logs and metrics without manual index management.
Use snapshots. A snapshot repository stores copies of the cluster data in shared storage such as object storage, and snapshots after the first are incremental. Automate them with snapshot lifecycle management, and test a restore regularly. Copying data directories from a running node is not a safe backup.
Use the bulk API with batches of a few megabytes, send from several threads, and raise the refresh interval or turn replicas off during a large initial load. Use explicit mappings, avoid unneeded fields and let Elasticsearch generate document IDs where possible. Monitor bulk rejections as a sign of overload.
Put exact conditions in filter context so they are cached, avoid leading wildcards and deep pagination, and keep shard counts sensible. Use routing for tenant based data and force merge on indices that no longer change. Profile slow queries with the profile API, and check that the file system cache has enough memory.
Elasticsearch 8 and 9 are heavily used for retrieval in AI applications. Expect at least one question here in a 2026 interview.
Vector search stores each document as a dense vector of numbers, an embedding that captures meaning, in a dense_vector field. A kNN query finds the stored vectors closest to the vector of the query, so it can find results with similar meaning, even when no words match. It is the base of semantic search and retrieval for AI answers.
Hybrid search combines keyword search, such as BM25, with vector search, then merges the two result lists, commonly using reciprocal rank fusion. It beats either method alone, since keywords catch exact names and codes while vectors catch meaning. Elasticsearch offers retrievers to describe such combined searches in one request.
The semantic_text field type simplifies semantic search by handling the chunking and the embedding for you. You map a field as semantic_text, index plain text, and Elasticsearch creates the embeddings through an inference endpoint. You then search with a semantic query. This removes the pipeline code that older versions needed.
Better Binary Quantization, or BBQ, compresses each vector dimension to a single bit, which cuts the memory needed for large vector indices dramatically while keeping good recall, especially when combined with a rescoring step. It reached general availability in the 9.x line and is a key cost control for big vector workloads.
Be ready to place Elasticsearch in a wider system and to say when not to use it.
The Elastic Stack is Elasticsearch for storage and search, Kibana for dashboards and exploration, Logstash for server side data processing, and Beats and Elastic Agent for collecting data from machines. Older material calls it the ELK Stack. Teams may also use Kafka as a buffer in front of the pipeline.
A relational database is built for transactions, joins and strict consistency. Elasticsearch is built for fast full text search, filtering and aggregations over large volumes, with eventual visibility of writes. Do not use it as the only source of truth for transactional data. Keep the record in a database and index a copy for search.
| Point | Elasticsearch | Relational database |
|---|---|---|
| Strength | Search and analytics | Transactions and joins |
| Consistency | Near real time visibility | ACID transactions |
| Joins | Limited | Full support |
| Schema | Flexible mapping | Fixed schema |
Prefer denormalisation, which means storing related data together in one document, because joins are costly. For arrays of objects that must be matched together, use the nested type. Parent and child joins exist but are slower and are rarely the first choice. In ES|QL, a lookup join can enrich results from a small index.
All three use Lucene. Solr is an older Apache project with its own query and configuration style. OpenSearch is a fork of Elasticsearch 7.10 maintained by AWS and a community. The APIs are similar for basic use but have diverged, so check the version and the client library before moving between them.
State what you would check first, then the fix, and finish with how you would prevent it.
Yellow means some replicas are unassigned. Check the allocation explain API to see why, which usually shows the node is still rejoining, a disk watermark is blocking allocation or allocation is disabled. Wait for recovery on a normal restart, free disk space if a watermark was hit, and confirm health returns to green.
Use the slow log and the profile API to find the expensive queries. Check shard size and count, heap use, merge pressure and whether filters are cached. Common fixes are moving exact conditions into filters, replacing leading wildcards, reducing deep paging, adding replicas for read load and splitting or rolling over an oversized index.
Create a new index with the correct mapping, reindex the data into it, keep applications reading through an alias, and switch the alias to the new index in one atomic call. If writes continue meanwhile, reindex again from a timestamp, or write to both indices briefly, before the switch.
Use a data stream with index lifecycle management. Keep recent data on hot nodes, move to warm and cold tiers as it ages, and use searchable snapshots for the frozen tier. Set retention to what compliance needs, drop unneeded fields at ingest, and use best compression. Size shards between 10 and 50 gigabytes.
First restore service: bring the node back, and check that primaries are assigned. Then find the cause, such as too many shards, large aggregations, a mapping explosion or fielddata on text fields. Fix with fewer shards, circuit breaker limits, doc values and query limits. Add heap monitoring and alerts for the future.
Index products with explicit mappings, a text field with an analyzer suited to the language, keyword fields for facets such as brand and category, and numeric fields for price. Use a bool query with filters for facets, boosts for relevance, and aggregations for the filter counts. Add synonyms and a completion suggester, and measure with click data.
What the interviewer is listening for: You separate text fields from facet fields, and you mention measuring relevance with real user behaviour.
Prepare indices, shards and replicas, mappings and analyzers, the bool query, aggregations and cluster health first. Then study the indexing path, segments, shard sizing and lifecycle management. In 2026 also learn vector and hybrid search. Be ready to write a query by hand and to explain a slow search.
It stores and indexes data, but it is a search and analytics engine, not a replacement for a transactional database. It offers near real time visibility of writes and limited joins. Most systems keep the source of truth in a database and use Elasticsearch for search and analysis.
Learn the current 9.x line, since the basics carry over from 8.x. Know the removed items that older tutorials still show: mapping types, the filtered query, the default of five shards and the need to install Java. Check the official release notes for what is new.
You should know Kibana at a basic level, because Dev Tools is the usual place to run queries and Discover and dashboards are the usual tools for logs. Practise reading a query response and building a simple chart.
Run a single node with the official container or package, load a sample dataset, and try the queries in Kibana Dev Tools. Build a small product search, then break it on purpose by creating a bad mapping, and fix it using reindex and an alias.
Use this plan if you have about a month before your interview.
| Week | Focus | What to do |
|---|---|---|
| Week 1 | Core concepts | Install a single node and Kibana. Index documents, and practise mappings, analyzers and the analyze API. |
| Week 2 | Queries and aggregations | Write bool, match, term and range queries, and bucket and metric aggregations on a sample dataset. |
| Week 3 | Architecture and operations | Study shards, segments, the translog, health colours, snapshots and lifecycle management. |
| Week 4 | Vector search and scenarios | Try a semantic or hybrid search, then practise the scenario questions aloud. |
If you want to practise these questions with a trainer and work on hands on projects, you can book a free demo class for the Prwatech Big Data course. It covers search and analytics tools, data pipelines and hands on projects.
Contact the learning team for current batch dates and fees.
Written by Mithun Ray, data engineering trainer at Prwatech. Reviewed by Avishekh Verma. Last updated October,2026.