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

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

About this method # A

Move or rename an index.

Using this method, you can keep your existing service running while data from the old index is added to the new index. Moving doesn’t trigger a complete rebuild of the destination index unless it has replicas.

Moving an index is expensive and is rate-limited:

  • If you have more than 100 pending requests, the engine throttles your requests.
  • If you have more than 5,000 pending requests, further requests are ignored.

Analytics#

If an index has analytics data, renaming doesn’t erase it but be aware of the consequences:

  • The destination’s analytics keep their original name
  • A new set of analytics is started with the new name.

To access the original analytics in the dashboard’s Analytics menu, first create a new empty index with the original index name.

If your source index doesn’t exist, the move operation is ignored. You can still use waitTask for this job.

Moving indices between apps#

To move an index between apps, use the copyIndex method.

Moving from and to replicas#

You can move a source index to a destination index that has replicas. The process replaces the destination index with the source index , and copies the source data to its replicas.

You can’t move a source index that has replicas.

Examples # A

Move index#

1
2
3
4
5
6
7
8
9
10
11
<?php
require_once __DIR__."/vendor/autoload.php";
use Algolia\AlgoliaSearch\SearchClient;

// Use an API key with `addObject` ACL
$client = SearchClient::create(
  'AJ0P3S7DWQ', 'YourAPIKey'
);

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

Parameters # A

Parameter Description
indexNameSrc #
type: string
Required

Index name of the index to move.

indexNameDest #
type: string
Required

Index name of the destination index.

Response # A

This section shows the JSON response returned by the API. Each API client encapsulates this response inside objects specific to the programming language, so that the actual response might be different. You can view the response by using the getLogs method. Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.

JSON format#

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

The date, in Unix timestamp format, when the job to copy the index was created.

taskID #
integer

The taskID used with the waitTask method.

You can use either the source or destination index to wait on the resulting taskID. In either case, the wait includes the entire copy process.

Did you find this page helpful?
PHP v3