What is the Reindex API and when would you use it?

Answer

The Reindex API (POST /_reindex) copies documents from a source index to a destination index. The primary use case is zero-downtime index migrations: when you need to change a field mapping (e.g., change a text field to keyword), you create a new index with the correct mapping, reindex data from the old index to the new one while the old index continues serving traffic, then atomically switch an alias from old to new. Reindex also supports a query to copy only matching documents, a script to transform documents during copying, and cross-cluster reindexing. It can be slow for large indexes — use slices for parallel execution.