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.
<?phprequire_once__DIR__."/vendor/autoload.php";useAlgolia\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');
1
2
3
4
5
6
7
8
9
require'algolia'# Use an API key with `addObject` ACLclient=Algolia::Search::Client.create('YourApplicationID','YourAPIKey')# Rename `indexNameSrc` to `indexNameDest` (and overwrite it)client.move_index('indexNameSrc','indexNameDest')
1
2
3
4
5
6
7
constalgoliasearch=require('algoliasearch');// Use an API key with `addObject` ACLconstclient=algoliasearch('YourApplicationID','YourAPIKey');// Rename indexNameSrc to indexNameDest (and overwrite it)client.moveIndex('indexNameSrc','indexNameDest');
1
2
3
4
5
6
7
fromalgoliasearch.search_clientimportSearchClient# Use an API key with `addObject` ACL
client=SearchClient.create("YourApplicationID","YourAPIKey")# Rename `indexNameSrc` to `indexNameDest` (and overwrite it)
client.move_index("indexNameSrc","indexNameDest")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
importAlgoliaSearchClient// Use an API key with `addObject` ACLletclient=SearchClient(appID:"YourApplicationID",apiKey:"YourAPIKey")// Rename `indexNameSrc` to `indexNameDest` (and overwrite it)client.moveIndex(from:"indexNameSrc",to:"indexNameDest"){resultinifcase.success(letresponse)=result{print("Response: \(response)")}}
1
2
3
4
5
6
7
8
// Use an API key with `addObject` ACLvalclient=ClientSearch(ApplicationID("YourApplicationID")APIKey("YourAPIKey"))// Rename `indexNameSrc` to `indexNameDest` (and overwrite it)valindex=client.initIndex(IndexName("indexNameSrc"))index.moveIndex(IndexName("indexNameDest"))
1
2
3
4
5
6
7
8
// Use an API key with `addObject` ACLvarclient=newSearchClient("YourApplicationID","YourAPIKey");// Rename `indexNameSrc` to `indexNameDest` (and overwrite it)client.MoveIndex("indexNameSrc","indexNameDest");// Asynchronousawaitclient.MoveIndexAsync("indexNameSrc","indexNameDest");
1
2
3
4
5
6
7
8
// Use an API key with `addObject` ACLSearchClientclient=DefaultSearchClient.create("YourApplicationID","YourAPIKey");// Rename `indexNameSrc` to `indexNameDest` (and overwrite it)client.moveIndex("indexNameSrc","indexNameDest");// Asynchronousclient.moveIndexAsync("indexNameSrc","indexNameDest");
1
2
3
4
5
// Use an API key with `addObject` ACLclient:=search.NewClient("YourApplicationID","YourAPIKey")// Rename `indexNameSrc` to `indexNameDest` (and overwrite it)res,err:=client.MoveIndex("indexNameSrc","indexNameDest")
1
2
3
4
5
// Use an API key with `addObject` ACLvalclient=newAlgoliaClient("YourApplicationID","YourAPIKey")// Rename `indexNameSrc` to `indexNameDest` (and overwrite it)client.execute{moveindex"indexNameSrc"to"indexNameDest"}
1
2
# Rename `INDEX_NAME_SRC` to `INDEX_NAME_DEST` (and overwrite it)
algolia indices move INDEX_NAME_SRC INDEX_NAME_DEST
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.
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.