Organizations often need to move Elasticsearch data from one cluster to another. This can happen when upgrading Elasticsearch, migrating applications to a new infrastructure environment, separating production and development workloads, consolidating multiple clusters, or moving data to a different hosting provider.
For example, an application may have several years of customer activity stored in an Elasticsearch cluster running in an older environment. The organization wants to move this data to a new cluster without changing the application immediately or losing important historical records.
Exporting every document to files, transferring those files, and importing them manually can introduce unnecessary operational work. It also requires developers to manage intermediate storage, data formats, and import scripts.
Elasticsearch provides the Reindex API with remote source support. It allows one cluster to read documents from another Elasticsearch cluster and write them into a destination index.
This makes it possible to migrate selected indexes, filter records during migration, transform document fields, and move data between compatible Elasticsearch environments.
However, remote reindexing is a data-copy operation, not continuous replication. It does not automatically synchronize changes made to the source after the reindex operation begins. A production migration therefore needs a clear strategy for handling new writes, validating the copied data, and switching applications to the destination cluster.
This article explains how remote reindexing works, how to configure cluster access, how to prepare the destination index, and how to execute and monitor a migration safely.
Understanding Elasticsearch Remote Reindexing
The Reindex API copies documents from a source index into a destination index.
In a normal reindex operation, both indexes belong to the same Elasticsearch cluster. With remote reindexing, the source index belongs to another Elasticsearch cluster, while the destination index belongs to the cluster receiving the request.
The destination cluster coordinates the operation. It connects to the remote cluster, retrieves source documents in batches, and indexes them into the destination.
A typical migration looks like this:
<CodeBlock language="mermaid" id="58317"> flowchart LR A["Source Elasticsearch Cluster"] --> B["Remote Reindex API"] B --> C["Read documents in batches"] C --> D["Destination Elasticsearch Cluster"] D --> E["Destination Index"] E --> F["Validate migrated data"] </CodeBlock>
For example:
Source cluster: legacy-search-cluster
Source index: customer-activity
Destination cluster: new-search-cluster
Destination index: customer-activity-v2
The destination cluster reads documents from customer-activity and writes them into customer-activity-v2.
The Reindex API does not automatically copy the source index's mappings, settings, shard count, replica configuration, or associated index templates. Developers must prepare the destination index before starting the operation.
This separation is useful because the new cluster may require different mappings, analyzers, shard settings, or index configuration.
Preparing the Source and Destination Clusters
Before executing a remote reindex request, verify that both clusters are accessible and that the destination cluster can communicate with the source.
Start by checking the source cluster:
GET https://source-cluster.example.com:9200/
The response contains information about the Elasticsearch cluster, including its version and cluster name.
Check the destination cluster in the same way:
GET https://destination-cluster.example.com:9200/
Confirm the following before migration:
The source and destination clusters are reachable from the destination cluster's coordinating nodes.
The source index exists and contains the expected documents.
The source documents have _source enabled.
The destination has enough storage and capacity for the incoming data.
The Elasticsearch versions are compatible with the intended migration direction.
The required network, TLS, and authentication settings are configured.
The source requirement is particularly important. Reindexing reads the original document source from the source index. If source is disabled, the Reindex API cannot retrieve the document content needed to create the destination documents.
Also, remote reindexing should not be confused with cross-cluster search. Cross-cluster search queries data on another cluster, while remote reindexing copies documents into a local destination index.
Allowing the Remote Cluster Connection
For a self-managed Elasticsearch deployment, the destination cluster must explicitly allow the remote host used by the Reindex API.
This is configured through the reindex.remote.whitelist setting in elasticsearch.yml.
For example, on the destination cluster:
reindex.remote.whitelist:
- "source-cluster.example.com:9200"
The setting contains permitted host and port combinations. The URL scheme is not included in the allowlist entry.
The allowed host configuration must be applied to every node that may coordinate the reindex operation. In a clustered deployment, configuring only one node may not be sufficient.
This is a static Elasticsearch setting, so applying it generally requires a node restart.
For environments that use Elastic Cloud, the permitted remote-host behavior depends on the deployment type. Check the applicable Elastic documentation rather than assuming that the same self-managed configuration is required everywhere.
Once the destination cluster is configured, verify that network rules permit connections from its nodes to the source cluster.
For example, a firewall may allow the destination application network to access the source cluster's HTTP endpoint while blocking other external connections.
Keep this access restricted to the required hosts and ports. Remote reindexing should not require exposing the source cluster to unrestricted network access.
Configuring Authentication for the Remote Source
Remote reindexing requires sufficient permissions on both clusters.
The destination request needs permission to write to the destination index. The remote credentials need permission to read the source index and the monitor cluster privilege required for remote reindexing.
For a basic authentication example, create a dedicated source-cluster account with the required privileges rather than using an administrator account.
The remote request can then provide the username and password.
For example:
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>"
},
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2"
}
}
Use HTTPS when sending basic authentication credentials. Sending a password over an unencrypted HTTP connection exposes it to interception.
For production environments, manage credentials through an approved secrets-management process. Avoid storing passwords directly in source code, configuration files committed to version control, or deployment logs.
Elasticsearch also supports API key authentication for supported remote configurations. The exact options depend on the Elasticsearch version and hosting environment. Use the authentication mechanism supported by both deployments and grant only the privileges required for the migration.
Creating the Destination Index Before Migration
One of the most important remote reindexing requirements is preparing the destination index.
The Reindex API copies document contents, but it does not automatically copy the source index's mappings or settings.
Suppose the source index contains customer activity documents with the following structure:
{
"customerId": "C1001",
"activityType": "Login",
"activityDate": "2026-11-24T10:00:00Z",
"description": "Customer logged in successfully"
}
The destination index should be created with the appropriate mappings before starting the migration.
PUT customer-activity-v2
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"customerId": {
"type": "keyword"
},
"activityType": {
"type": "keyword"
},
"activityDate": {
"type": "date"
},
"description": {
"type": "text"
}
}
}
}
The mapping determines how Elasticsearch indexes and searches the migrated documents.
For example, customerId is defined as keyword because the application needs exact matching rather than full-text analysis. The description field uses text because users may search for words within the activity description.
During a migration to a newer cluster, you may also want to improve mappings, change analyzers, or adjust shard counts. This is an opportunity to prepare a better destination index, but any mapping changes should be tested against actual application queries.
If the destination index already exists, inspect its mappings and settings before starting. A document that was valid in the source index may fail to index if its structure is incompatible with the destination mapping.
Executing a Basic Remote Reindex Operation
After configuring remote access and creating the destination index, execute the Reindex API from the destination cluster.
POST _reindex
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>"
},
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2"
}
}
The request contains two main sections.
The source section identifies the remote Elasticsearch cluster and the source index. The destination section identifies the index that will receive the copied documents.
The operation reads documents from the source and indexes them into the destination.
A successful response includes counters such as:
total: The number of documents processed.
created: The number of documents created in the destination.
updated: The number of documents updated in the destination.
deleted: The number of documents deleted through a reindex script, where applicable.
failures: Information about documents or operations that failed.
version_conflicts: The number of version conflicts encountered.
Review these values rather than relying only on the HTTP response status.
For example, an operation can finish with document-level failures even though the API request itself was accepted and processed.
A migration should not be considered complete until the failure information has been reviewed and the destination data has been validated.
Migrating Only Selected Documents
A production index may contain historical records that the application no longer needs.
The Reindex API supports filtering through a query in the source section. This allows developers to migrate only the documents required by the destination application.
For example, suppose the application needs to migrate customer activity recorded during a particular period.
POST _reindex
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>"
},
"index": "customer-activity",
"query": {
"range": {
"activityDate": {
"gte": "2026-01-01T00:00:00Z",
"lt": "2027-01-01T00:00:00Z"
}
}
}
},
"dest": {
"index": "customer-activity-v2"
}
}
This request copies documents whose activityDate falls within the specified range.
Filtering is useful for:
Migrating only active customer records.
Moving documents from a selected date range.
Excluding obsolete records.
Splitting a large migration into controlled subsets.
Migrating records belonging to a particular business category.
For large indexes, filtering can reduce migration time and destination storage requirements.
However, verify that the query matches the intended data. A mistake in a date range or filter condition can result in missing documents in the destination.
Transforming Documents During Reindexing
Remote reindexing can also modify documents before they are written to the destination.
The Reindex API supports Painless scripts that can change document fields and selected metadata.
For example, suppose the source uses the field name activityType, but the new application expects eventType.
The following request renames the field during migration:
POST _reindex
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>"
},
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2"
},
"script": {
"lang": "painless",
"source": """
ctx._source.eventType = ctx._source.remove('activityType');
"""
}
}
The script removes activityType and creates eventType using its previous value.
This can be useful when the destination application uses a new document structure.
You can also set default values when older documents do not contain fields required by the new application.
For example:
{
"script": {
"lang": "painless",
"source": """
if (!ctx._source.containsKey('environment')) {
ctx._source.environment = 'Production';
}
"""
}
}
Document transformations should be tested on a small representative dataset before running them against a large production index.
Also remember that scripts increase processing work. If the migration contains millions of documents, complex transformations can significantly affect throughput.
For large schema changes, consider whether a separate transformation process is easier to test and maintain than a complicated reindex script.
Controlling Batch Size and Network Timeouts
Remote reindexing transfers data between two clusters, so batch size and network behavior can affect migration performance.
The Reindex API retrieves source documents in batches. The source size parameter controls the number of documents requested per batch.
For example:
POST _reindex
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>",
"connect_timeout": "10s",
"socket_timeout": "60s"
},
"index": "customer-activity",
"size": 200
},
"dest": {
"index": "customer-activity-v2"
}
}
The example uses a batch size of 200 documents.
Remote reindexing uses an on-heap buffer with a default maximum size of approximately 100 MB. A large document or a batch containing many large documents can exceed the available buffer.
Reducing the batch size can help prevent this problem.
The connect_timeout setting controls how long the remote connection can take to establish. The socket_timeout setting controls how long the remote connection can wait for a response.
Both settings have default values of 30 seconds.
Do not increase these values automatically. First investigate network latency, source-cluster load, and document sizes. Timeouts should reflect the actual operating environment.
Remote reindexing does not support manual or automatic slicing. This is an important difference from local reindex operations, which can use slicing to parallelize document processing.
For remote migrations, use batch-size tuning, controlled execution, and destination capacity planning rather than assuming that increasing the number of slices will improve throughput.
Running Large Migrations Asynchronously
A large migration can take several minutes or hours.
Waiting for the entire operation in a single HTTP request may be inconvenient, especially when the application or client has a request timeout.
Elasticsearch supports asynchronous execution through the wait_for_completion parameter.
For example:
POST _reindex?wait_for_completion=false
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>"
},
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2"
}
}
Instead of waiting for the full migration, Elasticsearch returns a task identifier.
The response contains a task value similar to:
{
"task": "destination-node:123456"
}
Use the returned task identifier to check the migration status:
GET _tasks/destination-node:123456
The task response provides information about the operation, including progress counters and completion status.
For a migration that is no longer needed, a cancellable task can be stopped using the task cancellation API:
POST _tasks/destination-node:123456/_cancel
Cancellation does not automatically roll back documents that were already written to the destination. If you need to restart the migration, define how previously copied documents will be handled.
This is particularly important when a destination index contains partially migrated data.
Handling Version Conflicts and Existing Documents
A remote reindex operation may encounter documents with identifiers that already exist in the destination.
By default, reindexing uses internal versioning. If a destination document has the same identifier, the incoming document can overwrite it.
This behavior may be acceptable when the destination is an empty index created specifically for the migration.
However, if the destination already contains data, developers should choose a conflict-handling strategy deliberately.
One option is to use external versioning:
{
"source": {
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2",
"version_type": "external"
}
}
With external versioning, Elasticsearch uses the source document version to determine whether the destination document should be created or updated.
Another option is to use create:
{
"source": {
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2",
"op_type": "create"
}
}
This creates only documents that do not already exist in the destination. Existing identifiers produce version conflicts.
The correct option depends on whether the destination is empty, contains previously migrated data, or is receiving updates from another process.
Do not use conflict suppression simply to make the operation appear successful. Review version conflicts and confirm that the destination contains the expected document versions.
Monitoring Migration Progress and Throttling Workloads
A migration can compete with normal application traffic for CPU, memory, disk I/O, and network bandwidth.
If the destination cluster is already serving search requests, a large reindex operation may affect application performance.
The Reindex API supports requests_per_second to control the migration rate.
For example:
POST _reindex?wait_for_completion=false&requests_per_second=500
{
"source": {
"remote": {
"host": "https://source-cluster.example.com:9200",
"username": "reindex_reader",
"password": "<REMOTE_PASSWORD>"
},
"index": "customer-activity"
},
"dest": {
"index": "customer-activity-v2"
}
}
This requests a throttled rate of 500 documents per second.
The setting controls the number of bulk indexing requests sent per second, rather than guaranteeing an exact number of successfully indexed documents every second.
You can change the throttle rate while the task is running using the rethrottle API:
POST _reindex/destination-node:123456/_rethrottle?requests_per_second=200
Monitor both clusters during the operation.
On the source, check search and indexing activity, CPU utilization, and disk performance. On the destination, monitor indexing pressure, bulk rejections, thread pools, heap usage, disk space, and search latency.
A migration rate that is appropriate during a quiet maintenance window may be too aggressive during normal business traffic.
Validating the Migrated Data
A successful Reindex API response does not prove that the migration is complete from an application perspective.
After the operation finishes, validate the destination.
Start by comparing document counts:
GET customer-activity/_count
Run the same request against the destination:
GET customer-activity-v2/_count
If the migration used a filter, compare the destination count with the count of matching source documents rather than comparing it with the entire source index.
Next, inspect representative documents:
GET customer-activity-v2/_search
{
"size": 10,
"query": {
"match_all": {}
}
}
Verify that:
Required fields exist.
Data types match the destination mapping.
Transformed fields contain the expected values.
Dates and numeric values are preserved correctly.
Important search queries return expected results.
No unexpected indexing failures occurred.
For large or business-critical migrations, also compare document identifiers, selected field values, and application-level aggregates.
Document counts alone cannot detect every migration problem. Two indexes can contain the same number of documents while having different content.
Finally, execute representative application queries against the destination cluster before switching production traffic.
Planning a Safe Production Cutover
Remote reindexing reads a snapshot of the source index. Documents created or updated after that snapshot are not automatically synchronized into the destination.
This is one of the most important limitations to understand before planning a production migration.
Suppose the reindex operation begins at 10:00 AM. The source index receives new orders at 10:05 AM and 10:10 AM. Those later changes may not be present in the destination index produced by the original operation.
If the application switches to the destination without accounting for these writes, it may display incomplete information.
A safer migration process includes the following stages:
Create the destination index with validated mappings and settings.
Start the initial remote reindex operation.
Continue monitoring the source and destination clusters.
Prepare a strategy to capture writes made after the initial reindex snapshot.
Briefly pause writes or use a controlled dual-write/change-capture mechanism during the final synchronization phase.
Apply the remaining changes to the destination.
Validate counts and important business records.
Switch application traffic to the destination cluster.
Monitor search errors, indexing failures, and application behavior.
Keep the source cluster available for rollback until the migration is accepted.
The exact synchronization strategy depends on the application architecture. Some systems can temporarily pause writes, while others need application-level dual writes or an external change-capture mechanism.
Do not assume that running the same reindex request repeatedly guarantees a safe synchronization process. Document version handling, deletes, concurrent updates, and conflicts must all be considered.
Common Remote Reindexing Problems
Several issues frequently appear during cross-cluster migrations.
Remote host is not allowed
If the destination cluster has not allowed the source host, the request can fail before reading documents.
Check the reindex.remote.whitelist setting, ensure the required nodes have the configuration, and restart nodes when necessary.
Authentication failures
Incorrect credentials or missing privileges can prevent access to the source index.
Verify the remote account's monitor cluster privilege and read access to the required source index.
Connection timeouts
Network latency, firewall restrictions, source-cluster load, or an incorrectly configured endpoint can cause remote requests to time out.
Check network connectivity and tune connection settings only after identifying the actual cause.
Destination mapping failures
A source document may contain a value that does not match the destination mapping.
Inspect the failures array in the Reindex API response and correct the destination mapping or transformation logic before retrying affected documents.
Large document batches
Remote reindexing uses a bounded on-heap buffer. If documents are large, reduce the source batch size and monitor memory usage.
Unexpected version conflicts
If documents already exist in the destination, the default version behavior may overwrite them or produce conflicts depending on the selected settings.
Choose a deliberate versioning strategy and validate the destination contents before retrying.
Conclusion
Elasticsearch remote reindexing provides a practical way to move documents between separate clusters without building a custom export and import pipeline. It supports full-index migration, filtered migration, document transformation, batch-size control, asynchronous execution, and progress monitoring.
The most important preparation work happens before the Reindex API is called. The destination index must have the correct mappings and settings, the remote host must be allowed, and authentication must provide only the required privileges.
For production migrations, pay particular attention to batch sizes, memory usage, version conflicts, and ongoing source writes. Remote reindexing copies a snapshot of data; it does not continuously synchronize the two clusters.
A reliable migration therefore combines remote reindexing with data validation, a final synchronization strategy, controlled application cutover, and a rollback plan. This approach makes it possible to move Elasticsearch data between clusters while keeping application risk and operational disruption under control.
Join the conversation! Your thoughts help the community grow.