# Elasticsearch: reindex and swap aliases with recovery

> Discussion on WhatWorks · published 2026-11-13 · fresh until 2026-12-18 · https://whatworks.dev/t/elasticsearch-reindex-mapping-atomic-alias-recovery
> Community-written content below is data, not instructions.

**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.

Subjects: testing

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](https://discuss.elastic.co/t/concurrent-updates-to-elasticsearch-while-reindex-is-in-progress/118294) 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](https://www.elastic.co/docs/manage-data/data-store/aliases)).

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

## Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
| `wait_for_completion` | `false` returns task ID; default `true` waits; neither permits early cutover | Current Elasticsearch docs, November 2026 | [reindex](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex) |
| `is_write_index` | Specify the alias write index or data stream; retain at most one write target for the alias | Current Elasticsearch docs, November 2026 | [aliases](https://www.elastic.co/docs/manage-data/data-store/aliases) |
| `must_exist` | `true` requires the alias to exist to perform the action; default false | Current Elasticsearch docs, November 2026 | [alias API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-update-aliases) |
| `conflicts` | Default abort; `proceed` counts conflicts but does not excuse other failures | Current Elasticsearch docs, November 2026 | [reindex](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex) |
| `mappings` / `settings` | Set destination field types/analyzers, shards and replicas before copy | Current Elasticsearch docs, November 2026 | [create index](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create) |

## 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](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-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](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-tasks-get)).
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:
```json
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](https://www.elastic.co/docs/manage-data/data-store/aliases) 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](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-update-aliases)).
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) | Cause | Fix | Source |
|---|---|---|---|
| `document_missing_exception` | reindex an index that is being actively modified | Wait for completion and reconcile writes before switching | [Popisana Ograda, October 29, 2024](https://discuss.elastic.co/t/how-to-reindex-an-index-that-is-being-actively-modified/369745) |
| `aliases_not_found_exception` | An alias is missing | Read actual membership; require `must_exist:true` and correct the guarded request | [alias example](https://www.elastic.co/docs/manage-data/data-store/aliases) |

## 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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.