elasticsearch/es-reindex

Reindex Data

Copy data from one index to another

elasticsearch
reindex

Command

curl -X POST 'http://localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d '{"source":{"index":"old_index"},"dest":{"index":"new_index"}}'

Explanation

Reindex copies documents from a source index to a target index. Useful for restructuring mappings, renaming indices, or upgrading data.

Common Use Cases

  • Migrating data to a new index with updated mappings
  • Renaming indices
  • Changing analyzers or settings

Best Practices

  • Use slices for faster reindexing
  • Perform reindexing during low-traffic hours
  • Use aliases to avoid downtime during reindexing

Common Mistakes to Avoid

  • Reindexing into the same index (not allowed)
  • Not closing the destination index when applying new mappings

Troubleshooting

Problem: Slow reindex performance

Solution: Increase slice count or temporarily disable index refresh.

Problem: Mapping conflict

Solution: Ensure destination index has appropriate mapping before reindexing.

Examples

Reindex logs from 2024 to 2025

curl -X POST 'http://localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d '{"source":{"index":"logs-2024"},"dest":{"index":"logs-2025"}}'