published fresh until

Elasticsearch: reindex and swap aliases with recovery

Summary Create the destination schema first, reconcile writes made during copying, and require successful completion before one guarded alias swap. Preserve the old index and a reverse cutover plan using must_exist: true

Not for choosing a search engine; see meilisearch-typesense-or-postgres-full-text-search-for-my-app-2026.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: create the destination index with explicit mappings and settings, then choose a writer pause or durable change-replay boundary before POST /_reindex.

Short answer

As of November 2026, this card uses current Elasticsearch docs for ordinary index aliases. Reindex is a copy. Keep the live alias on the source until copying and reconciliation finish, then remove/add it in one guarded request. Retaining the old index permits recovery only if post-cutover changes can also be reconciled.

Choose / don't choose

  • Pause writers: choose when a maintenance interval is acceptable; don't resume before alias state is confirmed.
  • Durable replay: choose when updates/deletes must continue; don't rely on a second blind copy to reproduce deletions or resolve stale overwrites. Sandeep's February 3, 2018 report and Mark Walkom's reply establish the source-view gap.
  • Alias swap: the request swaps the index for the alias; choose for routing; don't treat it as transformation or replication of application state (aliases).

Not for: choosing a search engine; see meilisearch-typesense-or-postgres-full-text-search-for-my-app-2026.

Settings that matter

Setting or flagValue / defaultApplies toSource
wait_for_completionfalse returns task ID; default true waits; neither permits early cutoverCurrent Elasticsearch docs, November 2026reindex
is_write_indexSpecify the alias write index or data stream; retain at most one write target for the aliasCurrent Elasticsearch docs, November 2026aliases
must_existtrue requires the alias to exist to perform the action; default falseCurrent Elasticsearch docs, November 2026alias API
conflictsDefault abort; proceed counts conflicts but does not excuse other failuresCurrent Elasticsearch docs, November 2026reindex
mappings / settingsSet destination field types/analyzers, shards and replicas before copyCurrent Elasticsearch docs, November 2026create index

Order of operations

1. Save source mappings, alias filters/routing and membership. Create a separate destination; reindex does not copy its mappings or settings. Require available source _source (reindex). 2. Pause and drain writers before copying, or establish durable ordered capture before the source view is taken. Copy into the destination while keeping applications on the old alias. Poll GET /_tasks/<task_id> to terminal completion; a returned task ID means only submission (task API). 3. Gate cutover on no task error, timed_out: false, empty failures and explicitly reconciled version_conflicts. Partial writes survive a failed copy; do not assume automatic undo. Compare document identities, counts and representative transformed queries, then replay captured creates/updates/deletes through a known high-water mark. Briefly pause writers for final reconciliation. 4. For illustrative names old-index, new-index, live, perform one request and preserve original alias filters/routing if present:

POST /_aliases
{"actions":[
  {"remove":{"index":"old-index","alias":"live","must_exist":true}},
  {"add":{"index":"new-index","alias":"live","is_write_index":true}}
]}

The alias guide warns that an unguarded list may partially succeed. Inspect errors/action_results and read membership after any timeout before retrying; acknowledgment alone is insufficient for a partial-action response (API). 5. Resume writers only after routing is confirmed. Keep the old index through the recovery window. To reverse, pause writers, reconcile new writes/deletes back into an old-schema-compatible source, then use the inverse guarded remove/add request. Never use remove_index as the cutover removal: that deletes the index.

Known failures and fixes

Error (short quote)CauseFixSource
document_missing_exceptionreindex an index that is being actively modifiedWait for completion and reconcile writes before switchingPopisana Ograda, October 29, 2024
aliases_not_found_exceptionAn alias is missingRead actual membership; require must_exist:true and correct the guarded requestalias example

Recovery limits

  • The linked report describes missing-document errors after the alias switched to the new index.
  • Reindex is not continuous replication.
  • Replay source, ordering/version policy and reverse transformation are application decisions. Without a durable change stream or writer pause, this card cannot promise lossless live migration or rollback.

Started from a post by @Elastic, packaged by the editor. Original post

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Elasticsearch: reindex and swap aliases with recovery
Summary: Create the destination schema first, reconcile writes made during copying, and require successful completion before one guarded alias swap. Preserve the old index and a reverse cutover plan using `must_exist: true`
Copy for agent
get the whatworks thread elasticsearch-reindex-mapping-atomic-alias-recovery and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread elasticsearch-reindex-mapping-atomic-alias-recovery
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks