Skip to main content
This page documents an earlier version of the API client. For the latest version, see Copy or move an index.
Required ACL: addObject You can copy the entire index (records, settings, synonyms, and rules) or one or more of the following scopes:
  • Settings
  • Synonyms
  • Rules
This method doesn’t copy the enableReRanking and mode settings.

Rate limiting

Copying an index is rate-limited:
  • If you have more than 100 pending requests, your requests are throttled.
  • If you have more than 5,000 pending requests, further requests are ignored.

Source indices

Copying a source index that doesn’t exist creates a new index with 0 records. If the source index has replicas, the replicas won’t be copied.

Destination indices

When copying indices within the same Algolia application, the destination index is replaced if it exists. You can’t copy an index between two Algolia applications, if the destination index exists. Everything apart from the analytics data is replaced. You can’t copy to a destination index that already has replicas.

Analytics

Copying an index has no impact on Analytics. You can’t copy an index’s analytics data.

Scopes

To copy parts of your source index, use the scope parameter. If you omit the scope parameter, everything is copied. For example, to copy an index’s settings and synonyms, but not records and rules, set the scope parameter to: ["settings", "synonyms"].
  • The scope is replaced completely. Different items belonging to the same scope are not merged. For example, with scope: "settings", all settings of the destination index are replaced with the settings of the source index.
  • Items in different scopes are preserved.
  • If you set the scope parameter, records aren’t copied.

Examples

Copy an index

// Use an API key with `addObject` ACL
var client = new SearchClient("YourApplicationID", "YourAPIKey");

// Copy `indexNameSrc` to `indexNameDest`
client.CopyIndex("indexNameSrc", "indexNameDest");

// Asynchronous
await client.CopyIndexAsync("indexNameSrc", "indexNameDest");

Copy parts of an index with scopes

// Use an API key with `addObject` ACL
var client = new SearchClient("YourApplicationID", "YourAPIKey");

// Copy only settings and synonyms from `indexNameSrc` to `indexNameDest`
List<string> scopes = new List<string>() {
    CopyScope.Settings,
    CopyScope.Synonyms
};

client.CopyIndex("indexNameSrc","indexNameDest",scope: scopes);

// Asynchronous
client.CopyIndexAsync("indexNameSrc","indexNameDest",scope: scopes);

Copy index between apps

// Copy `indexNameSrc` from app `SOURCE_APP_ID` to app `TARGET_APP_ID`
SearchClient sourceClient = new SearchClient("SOURCE_APP_ID", "SOURCE_API_KEY");
SearchClient targetClient = new SearchClient("TARGET_APP_ID", "TARGET_API_KEY");

SearchIndex sourceIndex = sourceClient.InitIndex("indexNameSrc");
SearchIndex targetIndex = targetClient.InitIndex("indexNameDest");

AccountClient accountClient = new AccountClient();

// Provide your 'Record' class for serializing the records during copying
// This method throws an exception if `targetIndex` exists
accountClient.CopyIndex<Record>(sourceIndex, targetIndex);

// Asynchronous
await accountClient.CopyIndexAsync<Record>(sourceIndex, targetIndex);

Parameters

indexDest
object
required
Destination index object.
indexNameDest
string
required
Name of the destination index.
indexNameSrc
string
required
Name of the source index to copy.
indexSrc
object
required
Source index object.
scope
list
An array containing any combination of the following strings:
  • settings
  • synonyms
  • rules
See more on how this parameter works.

Response

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.
updatedAt
date string
Date at which the job to copy the index has been created.

Response as JSON

This section shows the JSON response returned by the API. Each API client wraps this response in language-specific objects, so the structure may vary. To view the response, use the getLogs method. Don’t rely on the order of properties—JSON objects don’t preserve key order.
JSON
{
  "updatedAt": "2017-12-18T21:22:40.761Z",
  "taskID": 19541511530
}
I