liveBook · Manning

Reindexing

As explained in Elasticsearch in Action, Second Edition

The Elasticsearch Reindex API copies documents from a source index to a destination index, optionally applying transformations during the operation.

Reindexing copies documents from one Elasticsearch index into another. Use it when an existing index needs settings or mapping changes that cannot be safely applied in place, or when primary-shard capacity was planned incorrectly. section 3.5 section 4.3.3

The safe pattern is to create a destination index with the required mapping and settings, copy documents into it, verify it works, switch the application, and then remove the old index. An alias can make the switch seamless and support zero-downtime migration. section 4.3.3 section 5.7

Copy movies into an updated index

Send a POST request to `_reindex`. `source.index` names the existing `movies` index; `dest.index` names `movies_new`, which should be prepared with the updated schema or settings. The operation takes a snapshot of the source and writes its records to the destination. section 5.7

Listing 5.50 Migrating data between indexes using the _reindex API
POST _reindex
{
  "source": {"index": "movies"},
  "dest": {"index": "movies_new"}
}

Use this request shape to migrate documents from `movies` to `movies_new`. Replace both names with the source and prepared destination indexes for your migration. section 5.7

Keep these operational limits in mind:

  • Primary-shard counts cannot be changed on an operating index because routing depends on that count; create a new index and reindex instead. section 3.5
  • Changing a field type on a live index is prohibited because existing indexed data follows the original schema; migrate into an index with corrected declarations. section 4.3.3
  • Reindexing can support production migration without downtime when paired with aliases, but consider its performance implications. section 5.0 section 5.7

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Shows the source-and-destination request format and migration workflow, while deferring detailed production scaling guidance.
Examples
Demonstrates copying `movies` to `movies_new` and presents generic source and destination index placeholders.
What it assumes
Assumes familiarity with Elasticsearch indexes and documents while introducing the `_reindex` request structure directly.
What you can do after
Operate/configure a replacement-index migration with `_reindex` and plan an application switch after verification.
How it connects
Connects reindexing to mappings, primary shards, routing, aliases, and zero-downtime migration.

Also explained in

Compare how 2 books explain reindexing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.