Move Index
addObject
ACL
$client->moveIndex( string indexNameSrc, string indexNameDest );
About this method
We released a new version of the PHP API client in public beta. Read the beta documentation for more information.
We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.
We released a new version of the Java API client in public beta. Read the beta documentation for more information.
You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.
You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.
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
Read the Algolia CLI documentation for more information.
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(
'YourApplicationID', 'YourAPIKey'
);
// 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. |
Response
This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here. You can view the response in the logs (using the getLogs
method).
JSON format
1
2
3
4
{
"updatedAt": "2017-12-18T21:22:40.761Z",
"taskID": 19541511530
}
updatedAt
|
string
The date, in Unix timestamp format, when the job to copy the index was created. |
taskID
|
integer
The You can use either the source or destination index to wait on the resulting |