Guides / Sending and managing data / Manage indices and apps / Manage indices

You can copy, or, duplicate whole indices, including records, settings, synonyms, and rules. You can copy indices within an Algolia application in the dashboard and with the API. If you want to copy an index between two Algolia applications, you can use the API.

Copying an index doesn’t copy the associated analytics data.

Copying an index is resource-intensive and is rate-limited.

Copy indices in the Algolia dashboard

Copying an index duplicates the records and configuration, including synonyms and rules of an existing index (except the enableReRanking setting).

To copy or duplicate an index in the dashboard:

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Algolia Search Search.
  3. Select the Algolia index you want to configure:

    Select your Algolia application and index

  4. Select Manage index > Duplicate.

    Duplicate your index, including settings, Rules, and synonyms.

  5. Select Create a new index or Overwrite an existing index and enter the name of the destination index.

  6. Enter DUPLICATE to confirm (if you’re overwriting an existing index) and click Duplicate.

Copy indices with the API

To copy indices, use one of these methods:

By providing a scope parameter or command-line option, you can choose what you want to copy: records, settings, synonyms, or rules.

Copying an index has no impact on Analytics, because you can’t copy an index’s analytics data. The API keys of the source are merged with the existing keys in the destination index.

Copy indices fully

To copy an index including records, settings, synonyms, and Rules, use the copyIndex method without arguments:

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'
);

// Copy `indexNameSrc` to `indexNameDest`
$client->copyIndex('indexNameSrc', 'indexNameDest');

If an index with the new name already exists, it’s overwritten after the renaming.

To prevent overwriting existing indices, you can check if an index exists with the indexExists method.

If the source index doesn’t exist, copyIndex creates an empty index with zero records under the new name. To prevent this, you can also use the indexExists method to see if the source index exists before copying.

Copy indices partially

To copy parts of an index, you can use the scope parameter. For example, to copy only the synonyms and settings (but not records or Rules) between indices:

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

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

// Copy only settings and synonyms from `indexNameSrc` to `indexNameDest`
$client->copyIndex('indexNameSrc', 'indexNameDest', [
  'scope' => ['settings', 'synonyms']
]);

If you use the scope parameter, records aren’t copied to the new index. Existing items of the scope are replaced. Items belonging to other scopes are preserved. For example, if you use the settings scope, only the settings are copied to the destination index, keeping the records, synonyms, and Rules.

For more information, see Scopes.

Indices with replicas

Copying a source index that has replicas copies the index’s data, but not its replicas. The destination index won’t have replicas.

You can’t copy to a destination index that already has replicas.

Copy indices between different applications

To copy an index between different Algolia applications, use the AccountClient, which is part of the Algolia API clients, or use the Algolia CLI.

For JavaScript, the AccountClient is distributed as a separate package @algolia/client-account. You can install it from npm:

1
npm install @algolia/client-account
1
2
3
4
5
6
7
8
use \Algolia\AlgoliaSearch\SearchClient;
use \Algolia\AlgoliaSearch\AccountClient;

// Copy `indexNameSrc` from app `SOURCE_APP_ID` to app `TARGET_APP_ID`
$sourceIndex = SearchClient::create('SOURCE_APP_ID', 'SOURCE_API_KEY')->initIndex('indexNameSrc');
$targetIndex = SearchClient::create('TARGET_APP_ID', 'TARGET_API_KEY')->initIndex('indexNameDest');

AccountClient::copyIndex($sourceIndex, $targetIndex);

If you copy an index to a different Algolia application, the targetIndex must not exist, or the process fails.

If you want to move an index between Algolia applications, you can copy it first, and then delete it.

Copy index settings

If you want to copy only an index’s setting to another index, you can use the Manage index > Copy Settings action in the dashboard, or the copySettings method of the API clients.

Did you find this page helpful?