Move indices
If you want to rename indices, you can move them using the Algolia dashboard or the API. Moving an index doesn’t move the associated analytics data. You can only rename primary indices.
Renaming replica indices requires several steps.
Moving or renaming an index is resource-intensive and is rate-limited.
Rename indices in the Algolia dashboard
- Go to the Algolia dashboard and select your Algolia application.
- On the left sidebar, select Search.
-
Select your Algolia index:
-
Select Manage index > Rename.
The Rename option only shows if you selected a primary index. It doesn’t show for replica indices.
-
Enter the current and new index names and click Rename.
If an index with the new name already exists, it’s overwritten.
Rename indices with the API
To rename or move an index with the API, use one of these methods:
- API clients:
moveIndex
- Algolia CLI:
algolia indices move
To move an index between different Algolia applications, see Copy indices between apps.
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');
If an index with the new name already exists, move
overwrites it.
If you want to avoid overwriting existing indices,
you can check if an index exists with the indexExists
method.
If the source index doesn’t exist, Algolia ignores the move
operation.
Renaming an index doesn’t change the associated analytics:
- Analytics belonging to the original index keep their name.
- A new set of analytics is started with the new name.
See Indices and analytics for more information.
Indices with replicas
You can’t move a source index with replicas. It would break the relationship between the index and its replicas.
You can move an index to a destination index with replicas. First, the source index data replaces the destination index data. Then, the data is copied to the replicas.
Moving indices used as a Recommend data source
If an index is the data source for Recommend models, you can’t rename it directly. If you do so, you’ll lose the relationship between the recommended records and their source.
Instead:
- Copy the index.
- To keep the events you already collected, train a new model on the copy index using the old index as an additional events source.
- After training, switch your own apps and services to use the new index.
- Delete the old index and the old model (from the Algolia dashboard).