API Reference / API Methods / Manage indices / Move index
Required API Key: any key with the addObject ACL
Method signature
$client->moveIndex(
  string indexNameSrc,
  string indexNameDest
);

About this method

You are currently reading the JavaScript API client v4 documentation. Check our migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You are currently reading the Ruby API client v2 documentation. Check our migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

Rename an index. Normally used to reindex your data atomically, without any down time.

The move index method is a safe and atomic way to rename an index.

By using this method, you can keep your existing service running while the data from the old index is being imported into the new index.

This method doesn’t trigger a complete rebuild of the destination index unless it has replicas.

Moving an index overrides the objects and settings of the destination index, with the objects and settings of the source index.

Before performing a move operation, make sure your source index exists. Our API creates a job even when an index doesn’t exist, but because it has no source index, the job won’t be able to end. If you perform a waitTask for this job, the wait will never resolve.

Regarding replicas:

  • Moving to an index having replicas is possible, it will replace the destination index data with the source index data, and the data will be propagated to the replicas
  • Moving an index having replicas is not possible, as it would break the relationship with its replicas

Note this is an expensive operation:

  • when you have more than 100 requests pending, your requests will be throttled.
  • when you have more than 5000 requests pending, further requests will be ignored.
  • if needed, these values can be tuned through configuration.

Moving an index will have no impact on Analytics data because you cannot move an index’s Analytics data.

Examples

Move index

1
2
// Rename indexNameSrc to indexNameDest (and overwrite it)
$index = $client->moveIndex('indexNameSrc', 'indexNameDest');

Parameters

indexNameSrc
type: string
Required

Index name of the index to move.

indexNameDest
type: string
Required

Index name of the destination index.

indexSrc
type: object
Required

Source index object.

indexDest
type: object
Required

Destination index object.

Response

In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.

JSON format

1
2
3
4
{
  "updatedAt": "2017-12-18T21:22:40.761Z",
  "taskID": 19541511530
}
updatedAt
string

Date at which the job to copy the index has been created.

taskID
integer

This is the taskID which is used with the waitTask method.

Note You can use either the source or destination index to wait on the resulting taskID. In either case, the wait will include the full copy process.

Did you find this page helpful?