Skip to content

Migrate Elasticsearch to OpenSearch

Migrate from Elasticsearch to OpenSearch via snapshot restore (≤7.10) or reindex-from-remote (7.11+). Covers index settings, ILM/ISM, dashboards, and client cutover.

Migrating from Elasticsearch to OpenSearch is a real project, not a config flip — the data format is compatible up to 7.10, then diverges, and the dashboards, ILM/ISM, security model, and client libraries are not portable. This article is a runbook for the two practical migration paths: (1) snapshot-restore from ES ≤ 7.10, and (2) reindex-from-remote for ES 7.11+ and 8.x. Audience is operators planning a real migration.

How to verify

Before, during, and after migration, these commands establish ground truth:

# Source ES
curl -sk -u elastic:"$PW_ES" 'https://es-source:9200/' | jq '.version'
curl -sk -u elastic:"$PW_ES" 'https://es-source:9200/_cat/indices?v&s=index'
curl -sk -u elastic:"$PW_ES" 'https://es-source:9200/_cluster/stats?filter_path=indices.docs.count,indices.store.size_in_bytes'

# Target OpenSearch
curl -sk -u admin:"$PW_OS" 'https://os-target:9200/' | jq '.version'
curl -sk -u admin:"$PW_OS" 'https://os-target:9200/_cat/indices?v&s=index'
curl -sk -u admin:"$PW_OS" 'https://os-target:9200/_cluster/stats?filter_path=indices.docs.count,indices.store.size_in_bytes'

# Per-index doc count parity
for idx in products users logs-2026.06.01; do
  src=$(curl -sk -u elastic:"$PW_ES" "https://es-source:9200/${idx}/_count" | jq .count)
  tgt=$(curl -sk -u admin:"$PW_OS"   "https://os-target:9200/${idx}/_count" | jq .count)
  echo "$idx  src=$src  tgt=$tgt"
done

Doc-count parity per index is the floor; sample query parity is the next bar.

What’s happening

OpenSearch forked from Elasticsearch 7.10.2. The Lucene-level data format is identical at that point. Two consequences:

  • ES ≤ 7.10 → OpenSearch: snapshot/restore works directly. OpenSearch can read the snapshot repository written by Elasticsearch 7.x.
  • ES 7.11+ → OpenSearch: snapshot restore is blocked by version checks in OpenSearch (the snapshot metadata identifies the source as a newer ES build). The path is reindex-from-remote — OpenSearch pulls docs over HTTP from the ES cluster and rebuilds the index.

Reindex-from-remote is slower (network-bound) but works at any version delta. For very large indices (terabytes), break the work into time-bounded reindex jobs and run them concurrently.

Beyond data: ILM policies don’t migrate (rewrite as ISM), index templates need the lifecycle.name reference adjusted, dashboards need to be exported from Kibana and imported into OpenSearch Dashboards (some won’t import cleanly), and client libraries must be swapped (elasticsearch-py → opensearch-py, etc.).

The procedure

Phase 1 — Plan

1. Inventory the source cluster.

curl -sk -u elastic:"$PW_ES" 'https://es:9200/_cat/indices?v&h=index,docs.count,store.size&s=store.size:desc' > inventory.txt
curl -sk -u elastic:"$PW_ES" 'https://es:9200/_ilm/policy?pretty' > ilm-policies.json
curl -sk -u elastic:"$PW_ES" 'https://es:9200/_index_template?pretty' > index-templates.json
curl -sk -u elastic:"$PW_ES" 'https://es:9200/_component_template?pretty' > component-templates.json

Classify indices: (a) write-active hot, (b) read-only warm/cold, (c) deprecated.

2. Decide cutover model.

  • Big bang — block writes on ES, migrate everything, switch reads to OpenSearch. Smallest dataset only.
  • Dual-write — application writes to both ES and OpenSearch during a window; replay backlog from ES; read cutover. The realistic choice for production.

Phase 2 — Stand up target

3. Provision OpenSearch. Match storage, RAM, node roles. Bring up the Security plugin with real certs from day one.

4. Translate templates. Component templates port mostly verbatim; the lifecycle references swap:

- "index.lifecycle.name": "logs-policy",
- "index.lifecycle.rollover_alias": "logs"
+ "plugins.index_state_management.rollover_alias": "logs"

Author an ISM policy equivalent to the ES ILM policy. There’s no frozen tier in OpenSearch open-source; collapse to cold.

5. Pre-create dashboards. Export from Kibana (Stack Management → Saved Objects → Export), import into OpenSearch Dashboards. Expect 10-30% manual rework — Lens visualizations and Maps are the worst offenders.

Phase 3 — Move data

Path A (ES ≤ 7.10): snapshot restore

6. Register the same S3 repository on OpenSearch:

curl -sk -u admin:"$PW_OS" -X PUT 'https://os:9200/_snapshot/migration-repo' \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "s3",
    "settings": {
      "bucket": "sh-es-backups",
      "region": "ca-central-1",
      "base_path": "prod-cluster/"
    }
  }'

7. Restore selectively:

curl -sk -u admin:"$PW_OS" -X POST \
  'https://os:9200/_snapshot/migration-repo/sh-2026.06.01-bk7/_restore' \
  -H 'Content-Type: application/json' \
  -d '{
    "indices": "products,users,logs-2026.05.*",
    "include_global_state": false,
    "rename_pattern": "(.+)",
    "rename_replacement": "$1"
  }'

Path B (ES 7.11+): reindex-from-remote

6’. Whitelist the source on OpenSearch. Edit opensearch.yml:

reindex.remote.whitelist: "es-source.internal:9200"
reindex.ssl.verification_mode: certificate

Restart OpenSearch.

7’. Reindex per index:

curl -sk -u admin:"$PW_OS" -X POST 'https://os:9200/_reindex?wait_for_completion=false' \
  -H 'Content-Type: application/json' \
  -d '{
    "source": {
      "remote": {
        "host": "https://es-source.internal:9200",
        "username": "elastic",
        "password": "'"$PW_ES"'"
      },
      "index": "products",
      "size": 1000
    },
    "dest": {"index": "products"}
  }'

Returns a task id. Track with _tasks/{task_id}. For large indices, slice into parallel jobs:

for i in 0 1 2 3; do
  curl -sk -u admin:"$PW_OS" -X POST 'https://os:9200/_reindex?wait_for_completion=false&slices='${i}'&max_docs=...' ...
done

Or use slices: auto for automatic slicing on a non-frozen source index.

Phase 4 — Cutover

8. Dual-write window. Update the application to write to both clusters. Most ORMs let you wrap the client; otherwise add a queue layer.

9. Replay backlog. After dual-write starts, replay the data written between the snapshot/reindex cutoff and the dual-write start.

10. Read cutover. Switch read traffic. Run the source ES cluster in dual-write-only mode for a few days as a safety net.

11. Decommission ES. Stop writes, take a final snapshot to cold storage, archive cluster configs, terminate.

Common pitfalls

  • Snapshot from 8.x will not restore to OpenSearch. Don’t waste a week trying — go straight to reindex-from-remote.
  • System indices (.security, .kibana) don’t migrate. Recreate the security model and dashboards from inventories captured in Phase 1.
  • Mappings with _xpack-specific types — ES-specific datatypes (e.g. wildcard, flattened after 7.10) don’t exist in OpenSearch. Audit before migrating; rewrite the mapping or split the data.
  • Client libraries. ES 8.x clients refuse to talk to OpenSearch. The application code must swap to opensearch-* clients before cutover. Plan the application release.
  • Per-index settings on cluster level. cluster.max_shards_per_node, allocation filters, and routing rules must be re-applied on OpenSearch; they’re not in snapshots or reindex.
  • Reindex throughput. Reindex-from-remote is HTTP, single-threaded per slice. A 1 TB index can take 12-24 hours even with slicing. Run during low-write windows.

In the engagements we run, a migration runs over weeks, not hours — the data move is the easy part, the application client swap and the dashboard rewrite are the long tail. We stage everything in a non-prod cluster first, run a dry-run cutover, then schedule the prod cutover during a low-traffic window. See /en/services/managed-operations/ for how we run search migrations as a planned project alongside ongoing operations.