Scrivio Interview library
ScenarioIntermediate6 min read · updated 13 November 2026

A product search index holds one document per SKU, 120 million documents, each with the brand name copied in. A brand rename must update 2 million documents; the update job saturated cluster CPU for 3 hours and search p99 rose from 80 ms to 1.4 seconds.

Why did the rename hurt so much, and how would you design the documents and the update path to cope with such changes?

In Lucene an update is a delete plus a full reindex of the document into a new segment, so renaming a brand copied into 2 million SKU documents rewrote 2 million documents and set off heavy merging that starved searches of CPU. Copying shared attributes into each document is still right for query speed, but fan-out updates must be throttled with requests_per_second and slices and run off-peak. Alternatively keep only a brand id and resolve the display name at query time, rebuild into a new index behind an alias for very large changes, and separate indexing from query load.

Why this question is asked

Denormalisation, copying data into each document so searches do not need joins, is the standard way to make search fast. Its hidden price is paid on the day a shared value changes, and the price is far higher in a search engine than in a database. The overview shows that day: one brand rename, three hours of saturated CPU, and p99 latency up seventeen times. Interviewers ask this to see whether we understand how Lucene updates work and can design documents and update paths with that in mind. In this answer, we will see why a Lucene update is expensive, why this rename hurt, how to throttle fan-out updates, how to model the brand differently, when to rebuild behind an alias, and how to protect query traffic, ending with the follow-up about nested and join fields.

1How an Update Works in Lucene

Each Elasticsearch or OpenSearch shard is a Lucene index made of segments, immutable files of indexed documents. Because segments are immutable, Lucene cannot change a field in place. An update, even of one field, fetches the full source document, applies the change, marks the old document as deleted, and indexes the whole new document into a new segment, running every field through its analyzers again.

Over time, many small segments and deleted documents accumulate, so a background process merges segments into larger ones, rewriting the live documents and dropping the deleted ones. Merging is IO and CPU heavy, and it competes with searches on the same nodes.

2Why the Rename Hurt So Much

Two million updates are therefore two million full reindexes of large product documents, each with its analysed text fields, plus two million deletions to clean up later. The update job probably ran as fast as the cluster would accept, perhaps with update_by_query at full speed. The cluster spent its CPU on analysis and indexing, created a stream of new segments, then spent more on merging them. Searches, which share those nodes, waited for CPU and disk, and their p99 rose from 80 ms to 1.4 seconds.

Notice that the denormalised design itself is reasonable: brand names are searched and faceted on, and copying them into each SKU keeps queries simple and fast. What was missing was a plan for the rare, wide update.

Step throughWhat one update costs in Lucene
  1. Fetch the full _source of the SKU
  2. Apply the new brand name
  3. Mark the old document deletedspace reclaimed only at merge
  4. Analyse and index the whole documentall text fields again
  5. Write to a new segment at refresh
  6. Merge segments in the backgroundrewrites live documents; heavy IO

6 steps in order. Play them, or step through them one at a time.

3Fix 1: Throttle Fan-Out Updates

The first fix is to make wide updates slow and steady on purpose. update_by_query and the reindex API accept requests_per_second, which spaces out batches, and slices, which splits the work into parallel parts so it can be tuned. We run such jobs off-peak, watch indexing and merge metrics and search latency while they run, and pause them if p99 rises. A rename that takes 10 hours at a gentle rate is far better than one that takes 3 hours and hurts every customer.

Java
POST /products/_update_by_query?requests_per_second=500&slices=auto&conflicts=proceed&wait_for_completion=false
{
"query": { "term": { "brand_id": "b-1234" } },
"script": { "source": "ctx._source.brand_name = params.n", "params": { "n": "Northwind Home" } }
}
// returns a task id; 2,000,000 docs at about 500/s take about 67 minutes
// POST _update_by_query/<task>/_rethrottle?requests_per_second=200 -- slow down live if p99 rises

The same throttling applies to a bulk job written in our own code: a bounded number of concurrent bulk requests of moderate size, with backoff when the cluster answers 429.

4Fix 2: Keep the Brand Id and Resolve the Name

If the brand's display name is not something users search on as text, there is no reason to copy it into 120 million documents. We keep only a brand_id keyword field in each SKU, which is used for filters and facets, and resolve display names at query time from a small lookup table of brands, held in memory or in a cache such as Redis. A rename then changes one row in that table and touches no SKU documents at all.

If users do search by brand name, we keep the searchable text denormalised but keep everything else, such as logos, descriptions and display formatting, out of the SKU document. The goal is to copy only the fields that need to be searched, and to accept that renames of those fields are rare, planned, throttled jobs.

5Fix 3: Rebuild Into a New Index for Very Large Changes

For changes that touch a large part of the index, such as a new analyzer, a mapping change, or a reorganisation of the brand catalogue, updating in place is the wrong tool. Instead we build a fresh index from the source of truth, with the new data, on nodes or at times that do not hurt search, and when it has caught up we switch an alias such as products from the old index to the new one in a single atomic request. The live index never sees the update and merge storm, and rollback is switching the alias back.

Choosing how to apply a wide change
ChangeApproachEffect on live search
Brand rename, 2 M docs, text searchedthrottled update_by_query, off-peaksmall, spread over hours
Brand rename, name only displayedkeep brand_id, resolve name at query timenone
New analyzer or mapping, all docsbuild new index, switch aliasnone until switch
Frequent changes to shared datarethink the model, or join fielddepends on model

6Separating Indexing From Query Load

Even with throttling, heavy indexing and searching on the same nodes compete. Larger clusters can separate them: dedicated ingest nodes for pipelines, a separate index or cluster that is built and then served, or, on platforms that support it, separate indexing and search replicas. At minimum we watch indexing rate, merge time, search thread pool queues and p99 latency together during big jobs, so the job can be slowed before users feel it.

7Follow-up questions

When would you choose nested or join fields instead of copying the brand into each SKU?

Nested fields are for arrays of objects inside one document, such as variants with their own colour and size, queried together correctly; updating any nested object still reindexes the whole document, so nested does not help with renames. A join field (parent-child) stores brands as parent documents and SKUs as children on the same shard, so a rename updates one parent. We would choose it when shared data changes often and queries can tolerate slower has_parent queries and the routing constraint. For a rare rename, denormalising plus throttled updates or an id lookup is simpler and faster to query.

Why not lower refresh_interval during the job?

Raising refresh_interval, for example to 30 seconds, during a large reindex into a new index is a good idea because it creates fewer, larger segments. On a live index that serves searches, it delays all other updates too, so we would only do it if a short delay in freshness is acceptable.

How do you know the update job is hurting search?

We watch search p99 and the search thread pool queue on the nodes, together with indexing rate and merge time. When search queues grow while merges run, the job is competing for resources and should be rethrottled.

8Conclusion

In this answer, we saw that a Lucene update is a delete plus a full reindex into a new segment, so a 2 million document rename caused heavy indexing and merging that starved searches. Denormalising is still right, but fan-out updates must be throttled with requests_per_second and slices and run off-peak. We can also keep a brand id and resolve names at query time, rebuild into a new index behind an alias for very large changes, and separate indexing from query load while watching merge and latency metrics.

What to say in the interviewAbout 80 seconds aloud

Open with

In Lucene, documents live in immutable segments, so an update is really a delete plus a full reindex of the whole document into a new segment, with all text fields analysed again, and the deleted copies are cleaned up later by merging.

Then, if they want more

So renaming a brand copied into 2 million SKUs meant rewriting 2 million documents and a lot of merge work, and with the job running flat out, searches on the same nodes waited for CPU and disk, which is why p99 went from 80 milliseconds to 1.4 seconds.

I would keep denormalising fields that are searched, because that is what keeps queries fast, but treat fan-out updates as planned jobs: update_by_query or bulk with requests_per_second and slices, off-peak, watching p99 and rethrottling if it rises.

If the brand name is only displayed, I would store a brand id and resolve the name at query time from a small cached lookup, so a rename touches nothing in the index. For very large changes, like a new analyzer, I would build a new index from the source and switch an alias atomically.

And on bigger clusters I would separate indexing load from query load and watch merge and indexing metrics during these jobs.

About this answer

Last updated
13 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 "Why did the rename hurt so much, and how would you design the documents and the update...": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/76e01c9e29/