Quick revision
The short answer
We stop reindexing in place: the new index is built in the background under a new name while the old one keeps serving, and an alias switch makes it live. Changes made during the rebuild are replayed from the event log or CDC stream so the new index catches up before the switch. The bulk load is parallelised by partition, with tuned bulk sizes and refresh and replicas turned off during the load, additive mapping changes are applied without reindexing where the engine allows, and the whole procedure is automated so it becomes routine instead of a release blocker.
What to remember
In this answer, we decoupled reindexing from releases by building the new index in the background behind an alias, recorded the stream position and replayed changes so the new index catches up before the switch, parallelised the bulk load with refresh and replicas off, avoided full reindexes for additive mapping changes, and automated the whole procedure with validation and rollback.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We stop reindexing in place: the new index is built in the background under a new name while the old one keeps serving, and an alias switch makes it live. Changes made during the rebuild are replayed from the event log or CDC stream so the new index catches up before the switch. The bulk load is parallelised by partition, with tuned bulk sizes and refresh and replicas turned off during the load, additive mapping changes are applied without reindexing where the engine allows, and the whole procedure is automated so it becomes routine instead of a release blocker.
Why this question is asked
A 14-hour reindex that must run before a release turns every mapping change into a scheduling problem: releases wait for a quiet window, teams batch changes to avoid reindexing, and a failed reindex means another day lost. The underlying mistake is that the index is rebuilt as part of the release rather than alongside it. Interviewers ask this scenario to see whether we can decouple the two and make reindexing safe, fast and boring. In this answer, we will see why the reindex blocks releases, build the new index in the background behind an alias, catch up with changes from the event log, speed up the bulk load, avoid reindexing where possible, and automate the whole procedure.
1Why the Reindex Blocks Releases Today
Search engines such as Elasticsearch and OpenSearch cannot change the type or analyser of an existing field in place. If we want the name field analysed differently, we must create a new index with the new mapping and load every document into it again. That part is unavoidable.
What is avoidable is the coupling. In the current process, the release that needs the new mapping also triggers the reindex, and the application cannot run until the new index is complete, because the code expects the new fields. So the release waits 14 hours. The fix is to make reindexing a separate, background operation that finishes before the release that needs it, and to have the application read through an alias rather than a fixed index name.
2Building the New Index in the Background
The application always queries the alias products. Today it points to products_v7. When a mapping change is needed, we create products_v8 with the new mapping and start loading it from the source of truth while v7 keeps serving every query. Users notice nothing.
The application code that depends on the new mapping must cope with both, or be released behind a feature flag that is switched on after the alias moves. Often the first release is simply one that tolerates both indices, then the alias switches, then a later release removes the old code path. Releases are no longer waiting for the reindex; they just need it finished before the flag is enabled.
3Catching Up With Changes Made During the Rebuild
While v8 is loading for hours, products keep changing. If we switched as soon as the bulk load finished, v8 would be missing every change since the load began. So before the load starts, we record the current position in the change stream, for example the Kafka offsets of the product topics or the CDC log position.
We then load a snapshot of all products into v8. When the snapshot is done, a catch-up consumer replays every event from the recorded position into v8. With external versions on every write, it does not matter that some replayed events are older than snapshot data; the engine keeps the newer version. Once the catch-up consumer is within seconds of the live stream, the indexer writes to both indices, and we switch the alias.
- Record stream positionKafka offsets or CDC log position
- Create products_v8new mapping, refresh off, no replicas
- Bulk load the snapshot in parallelpartitioned by id range
- Replay events from the recorded positionexternal versions keep newest data
- Lag under a few seconds?YesValidate counts and sample queriesNoKeep replaying
- Switch alias to products_v8keep v7 for rollback for a few days
6 steps in order. Play them, or step through them one at a time.
4Making the Bulk Load Much Faster
Fourteen hours usually means a single process reading the database and writing to the engine one batch at a time. The load is easy to parallelise because documents are independent. We split the product ids into, say, 32 ranges and run 32 loader workers, each reading its range with keyset pagination and sending bulk requests of about 5 to 15 MB. The engine's ingest capacity, not our loader, becomes the limit.
During the load we also change index settings that only matter for a live index. Turning off refresh avoids creating searchable segments every second, and setting replicas to zero halves the write work; we restore both before the switch, and the replicas then copy finished segments, which is much cheaper than indexing twice.
The source side matters too. Building each document should not run one query per product; the loader reads products, prices and categories in large batches and joins them in memory. With these changes, a load that took 14 hours commonly drops to one or two hours, and the exact number depends on cluster size, which we can also increase temporarily for the load.
5Avoiding Reindexing for Additive Changes
Many mapping changes do not need a reindex at all. Adding a new field to an existing index is allowed: we update the mapping with the new field, and new or updated documents fill it in. To populate it for existing documents, an update-by-query or a targeted reindex of affected products is enough. Multi-fields let us add a new way of indexing an existing field, for example a keyword version of name for sorting, which applies to documents as they are reindexed.
Only true changes, such as a different type or analyser for an existing field, need the full rebuild. Reviewing mapping changes with this in mind often removes the majority of full reindexes.
6Automating the Procedure
Finally, we turn the steps into a pipeline that anyone on the team can run with one command: create the index from a versioned template, record the stream position, run the parallel load, replay, validate document counts per category and run a set of sample queries comparing the old and new index, switch the alias, and keep the old index for a few days for rollback before deleting it. Each step reports progress and can be resumed.
When reindexing is automated and runs in a couple of hours without affecting users, it stops being an event. Mapping changes can ship weekly, and the release calendar no longer depends on the search team's evenings.
7Follow-up questions
What if the new mapping breaks queries after the switch?
We switch the alias back to v7, which is instant, because we kept it. The validation step, with sample queries compared between old and new, is designed to catch this before the switch.
Why replay from the event log instead of dual-writing from the start?
Both are used. Dual-writing from the start would send live changes to an index that is still being bulk loaded, which is fine with external versions, but recording the position and replaying is simpler to reason about and lets us restart the load without losing changes.
Is the Elasticsearch _reindex API an option?
Yes, when the source documents are already in the old index and do not need to be rebuilt from the database. It can run in parallel with slicing. If documents need data from the source, for example a new field, loading from the database is the better path.
8Conclusion
In this answer, we decoupled reindexing from releases by building the new index in the background behind an alias, recorded the stream position and replayed changes so the new index catches up before the switch, parallelised the bulk load with refresh and replicas off, avoided full reindexes for additive mapping changes, and automated the whole procedure with validation and rollback.
Open with
The real problem is that reindexing is coupled to the release. I would have the application always query an alias, then build the new index under a new name, say products_v8, in the background while v7 keeps serving.
Then, if they want more
Before starting, I record the Kafka offsets or CDC position, bulk load a snapshot from the source, and then replay events from that position into v8. Because writes use external versions, replayed older events cannot overwrite newer data.
When v8 is within a few seconds of live, the indexer writes to both, I validate counts and compare sample queries, and switch the alias atomically, keeping v7 for rollback. The application release that needs the new mapping goes behind a feature flag or tolerates both mappings, so releases no longer wait.
To shorten the 14 hours, I would parallelise the load by id ranges, tune bulk requests to around 5 to 15 megabytes, disable refresh and replicas during the load, batch the source reads, and possibly scale the cluster temporarily. Many changes, like adding a field, need no full reindex at all.
And I would automate the whole thing into one resumable pipeline so it becomes routine.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A full reindex of your product search index takes 14 hours and must happen whenever the...": https://scrivio-interview-library.netlify.app/architecture/backend-system-design/c7d2af9878/