Chapter 12 · Aliases, Rollover, Reindex, Update/Delete by Query, and Zero-Downtime Index Changes

Execute a Mapping Migration with Dual Read/Write or Alias Cutover, Validation, and Rollback Evidence

Combine schema preparation, write coordination, reindexing, validation, atomic alias switching, smoke tests and evidence-backed rollback into a repeatable zero-downtime migration workflow.

Intermediate110–135 minutesZero-downtime migration labElasticsearch 9.5.3 · OpenSearch 3.8.0Last reviewed: September 2026

Learning outcomes

AtlasMart now has every primitive needed for a safe migration: versioned mappings/templates, aliases, throttled reindex, task observation and reversible cutover. The remaining problem is coordination. A migration is correct only if the destination contains the intended historical documents and every write that occurred during the copy window.

01

Choose a write-coordination strategy—brief write freeze, dual write, change replay or equivalent—from explicit consistency requirements.

02

Run a v1→v2 migration with pre-created mappings, throttled reindex and deterministic validation evidence.

03

Switch read/write aliases atomically and run application-level smoke tests immediately after cutover.

04

Exercise rollback while tracking writes that occurred after cutover so rollback does not silently discard them.

05

Produce a migration evidence manifest covering correctness, latency, conflicts, resource impact, security and recovery.

Chapter baseline reviewed 11 September 2026

Examples target self-managed Elasticsearch 9.5.3 and OpenSearch 3.8.0 with the established AtlasMart lab conventions: Elasticsearch on https://localhost:9200 using the copied CA certificate, OpenSearch on https://localhost:9201 using the disposable demo certificate only for local learning, pinned server versions, and no moving latest tags. The lab uses a small local dataset and a brief write freeze because it is deterministic and free. Production systems with continuous writes may require dual writing, CDC/event replay or another coordination design. The chapter does not claim one strategy fits every workload.

Execution and measurement note

The generation environment does not run both search servers. Requests below are deterministic lab specifications reviewed against current product documentation. Expected output describes invariants, not fabricated captured results. Execute against disposable AtlasMart resources and record your own task IDs, counts, conflicts, throttling time, p95/p99 latency, CPU, disk growth and rollback evidence.

Execution and safety note

Run mutating, destructive, security, lifecycle, snapshot, failure-injection, and load-test commands only in the disposable AtlasMart lab or an equivalently isolated environment. Verify the target cluster, index, tenant, credentials, and rollback path before execution; treat shown output as an expected invariant unless the lesson explicitly labels it as captured evidence.

1. Define the change and the write window before touching data

Decision AtlasMart lab choice Production alternatives
Mapping change Add schema_version and keep other fields compatible New analyzer/type/nested model may require more extensive reindex/relevance tests.
Write coordination Brief write freeze during final sync/cutover Dual write; event-log replay; CDC; maintenance window.
Read cutover Atomic read alias switch Canary/shadow reads before full switch.
Rollback window Keep v1 untouched until verification completes Longer dual compatibility window if write replay is available.
Deletion No immediate source deletion Retire only after snapshot/restore and business approval.

Document the maximum acceptable stale window. If the application cannot stop writes, a plain one-pass reindex is insufficient because writes after the source snapshot may never reach v2.

2. Establish baseline aliases and evidence

Dev Tools · v1 and aliases
PUT atlasmart-products-v1
{
  "settings":{"number_of_shards":1,"number_of_replicas":0},
  "mappings":{"dynamic":"strict","properties":{
    "sku":{"type":"keyword"},
    "name":{"type":"text","fields":{"keyword":{"type":"keyword"}}},
    "category":{"type":"keyword"},
    "price":{"type":"scaled_float","scaling_factor":100},
    "available":{"type":"boolean"},
    "updated_at":{"type":"date"}
  }}
}

POST _bulk?refresh=true
{"index":{"_index":"atlasmart-products-v1","_id":"P-1001"}}
{"sku":"P-1001","name":"Wireless Noise Cancelling Headphones","category":"audio","price":199.99,"available":true,"updated_at":"2026-09-11T07:00:00Z"}
{"index":{"_index":"atlasmart-products-v1","_id":"P-1002"}}
{"sku":"P-1002","name":"USB-C Travel Charger","category":"power","price":49.95,"available":true,"updated_at":"2026-09-11T07:01:00Z"}
{"index":{"_index":"atlasmart-products-v1","_id":"P-1003"}}
{"sku":"P-1003","name":"Ergonomic Mechanical Keyboard","category":"input","price":129.00,"available":false,"updated_at":"2026-09-11T07:02:00Z"}


POST _aliases
{
  "actions":[
    {"add":{"index":"atlasmart-products-v1","alias":"atlasmart-products-read"}},
    {"add":{"index":"atlasmart-products-v1","alias":"atlasmart-products-write","is_write_index":true}}
  ]
}

GET _alias/atlasmart-products-read
GET atlasmart-products-read/_count

Record source count, representative IDs, aggregations and judged search fixtures. These become the comparison set. A screenshot alone is weak evidence; save machine-readable responses or a migration report in your change record.

3. Prepare v2 and run the historical copy

Create v2
PUT atlasmart-products-v2
{
  "settings":{"number_of_shards":1,"number_of_replicas":0},
  "mappings":{"dynamic":"strict","properties":{
    "sku":{"type":"keyword"},
    "name":{"type":"text","analyzer":"standard","fields":{"keyword":{"type":"keyword"}}},
    "category":{"type":"keyword"},
    "price":{"type":"scaled_float","scaling_factor":100},
    "available":{"type":"boolean"},
    "updated_at":{"type":"date"},
    "schema_version":{"type":"keyword"}
  }}
}
Throttled asynchronous reindex
POST _reindex?wait_for_completion=false&requests_per_second=25
{
  "source":{"index":"atlasmart-products-v1"},
  "dest":{"index":"atlasmart-products-v2"},
  "script":{"lang":"painless","source":"ctx._source.schema_version='v2'"}
}

GET _tasks?actions=*reindex*&detailed=true

During this phase, production writes still target v1 under the lab’s plan. In a real dual-write design, every write must be idempotently applied to both versions and error handling must detect one-sided success. In an event-replay design, persist a checkpoint that identifies exactly which changes occurred after the reindex snapshot.

4. Enter the controlled cutover window

Lab runbook · freeze, verify, switch
1. Stop/queue new product writes at the application boundary.
2. Wait for the historical reindex task to complete.
3. Replay or copy any writes after the reindex snapshot if your strategy permits them.
4. Compare source/destination counts and critical IDs.
5. Run aggregation checks and judged relevance fixtures.
6. POST _aliases once to move read + write aliases to v2.
7. Resume writes.
8. Execute read and write smoke tests through the aliases.
Atomic alias cutover
POST _aliases
{
  "actions":[
    {"remove":{"index":"atlasmart-products-v1","alias":"atlasmart-products-read"}},
    {"remove":{"index":"atlasmart-products-v1","alias":"atlasmart-products-write"}},
    {"add":{"index":"atlasmart-products-v2","alias":"atlasmart-products-read"}},
    {"add":{"index":"atlasmart-products-v2","alias":"atlasmart-products-write","is_write_index":true}}
  ]
}

5. Validate through the same interfaces the application uses

Smoke and semantic validation
GET _alias/atlasmart-products-read
GET atlasmart-products-read/_count
GET atlasmart-products-read/_search
{
  "query":{"match":{"name":"wireless headphones"}}
}

POST atlasmart-products-write/_doc/P-1999?refresh=true
{
  "sku":"P-1999",
  "name":"Migration Smoke Product",
  "category":"test",
  "price":1.00,
  "available":true,
  "updated_at":"2026-09-11T09:00:00Z",
  "schema_version":"v2"
}

GET atlasmart-products-read/_doc/P-1999

Also compare business aggregates and authorization paths. If the mapping/analyzer changed, run the Chapter 07 relevance regression set rather than assuming equal _score values. Record application p95/p99 during the cutover period and the cluster’s CPU/JVM/disk/search rejection behavior.

6. Exercise rollback, do not merely document it

Rollback alias transaction
POST _aliases
{
  "actions":[
    {"remove":{"index":"atlasmart-products-v2","alias":"atlasmart-products-read"}},
    {"remove":{"index":"atlasmart-products-v2","alias":"atlasmart-products-write"}},
    {"add":{"index":"atlasmart-products-v1","alias":"atlasmart-products-read"}},
    {"add":{"index":"atlasmart-products-v1","alias":"atlasmart-products-write","is_write_index":true}}
  ]
}

This rollback is only data-safe if v1 contains every write that must remain visible. The smoke product written after cutover exists only in v2 in this simple lab, so blindly rolling back would hide it. That concrete edge case is the reason a production rollback plan needs reverse replay, dual writing, or a rule that writes remain frozen until the acceptance window closes.

Rollback paradox

The fastest pointer rollback can be the least correct data rollback. Preserve a reversible write history or hold writes long enough to prove the new version before declaring rollback safe.

7. Deliberately wrong approach: delete v1 immediately after green smoke tests

A five-minute smoke test cannot prove long-tail queries, tenant permissions, delayed consumers, snapshots or operational behavior. Deleting v1 also removes the simplest rollback target. Repair by retaining v1 for a defined window, making it read-only if appropriate, taking/validating independent snapshots, monitoring v2, and retiring v1 only through a separate approved step.

8. Migration evidence manifest

Release gate
baseline versions: Elasticsearch 9.5.3 / OpenSearch 3.8.0
source mapping/settings captured: PASS
destination mapping/settings reviewed: PASS
write-coordination strategy: DOCUMENTED
source count / destination count: RECORDED
stable-ID sample comparison: PASS
critical aggregation comparison: PASS
relevance regression set: PASS
reindex task failures/conflicts: RECORDED
requests_per_second + slices: RECORDED
p95/p99 search/index latency during migration: MEASURED
CPU/JVM/disk/merge headroom: MEASURED
alias state before/after: CAPTURED
read smoke test: PASS
write smoke test: PASS
rollback drill: PASS
post-cutover write reconciliation: PASS
snapshot/restore evidence: PASS
source retirement date/owner: APPROVED

Replace every placeholder such as MEASURED or RECORDED with actual evidence before production approval. A migration report is part of the system’s operational correctness, not optional paperwork.

Check your understanding

  1. Why is one-pass reindex insufficient for a continuously written source?
  2. What should be switched atomically?
  3. Why can rollback after resumed writes lose data?
  4. When should v1 be deleted?
  5. What is the strongest migration evidence?
Review the answers

1. Writes after the source snapshot can be absent from the destination unless you freeze, dual-write, replay, or otherwise synchronize them.

2. The logical read/write alias mapping once destination validation and write synchronization are complete.

3. New writes may exist only in v2, so pointing back to v1 hides or discards them unless reverse synchronization exists.

4. Only after the rollback window, monitoring, snapshot/restore evidence and explicit retirement approval are complete.

5. A reproducible manifest covering data, search semantics, tasks/conflicts, resource impact, alias state, app smoke tests, security and rollback/recovery.

Production judgment

Zero downtime is not just “no HTTP 503 during alias switch.” It means the application remains available while data correctness, tenant isolation, acceptable freshness and recoverability are preserved. Choose the simplest write-coordination mechanism that meets those guarantees. For small systems that may be a short freeze; for high-throughput systems it can require durable event replay or dual-write infrastructure. Validate both Elasticsearch and OpenSearch behavior on the exact target version and managed-service environment before executing the runbook.

Chapter 12 summary and bridge to Chapter 13

You can now change physical indices without tying application endpoints to those indices, control copy/mutation tasks, and prove cutover/rollback with evidence. Chapter 13 turns to the topology beneath those operations: shard count, routing, allocation, awareness, recovery and the capacity headroom required for migrations and failures.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.