🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
Guides / Sending and managing data / Manage indices and apps / Manage indices

Deleting an index permanently removes the records and the index configuration, like searchable attributes and custom ranking, from your Algolia application.

Instead of deleting the complete index, you can also delete (clear) just the records, keeping the configuration. See Clear records from an index on this page for more information.

Before you delete an index, consider creating a backup by exporting your index.

Deleting an index doesn’t affect its analytics data.

If you accidentally delete an index, the Algolia support team might be able to restore it but there are no guarantees. However, daily backups are included as part of the Enterprise pricing plan add-on.

Indices with replicas

If the index you want to delete is a replica of another index, you must first unlink it.

If the index is a primary index and has replicas, the replica indices will become independent indices if you delete their primary index.

Delete indices in the Algolia dashboard

To delete an index from the dashboard:

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

    Select your Algolia application and index

  4. Select Manage index > Delete.

    Delete an index from the Algolia dashboard

  5. Type DELETE to confirm and click Delete.

Delete indices with the API

To delete an index, use one of these methods:

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

// Use an API key with `deleteIndex` ACL
$client = SearchClient::create(
  'YourApplicationID', 'YourAPIKey'
);
$index = $client->initIndex('YourIndexName');
$index->delete();

Delete multiple indices

To delete more than one index:

  1. Use listIndices (API client) or algolia indices list (Algolia CLI) to get your indices
  2. Use multipleBatch or algolia indices delete to delete multiple indices with a single request.

To delete replica indices, you must first delete their primary indices.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
require_once __DIR__."/vendor/autoload.php";
use Algolia\AlgoliaSearch\SearchClient;

// You need an API key with `deleteIndex` permissions
$client = SearchClient::create('YourApplicationID', 'YourAPIKey');

// List all indices
$indices = $client->listIndices();

// Primary indices don't have a `primary` key
$primaryIndices = array_filter($indices['items'], function ($index){
    return !isset($index['primary']);
});
$replicaIndices = array_filter($indices['items'], function ($index){
    return isset($index['primary']);
});

// Delete primary indices first
foreach ($primaryIndices as $i) {
  $index = $client->initIndex($i['name']);
  $index->delete()->wait();
}
echo "Deleted primary indices.\n";

// Now, delete replica indices
foreach ($replicaIndices as $i) {
  $index = $client.initIndex($i['name']);
  $index->delete()->wait();
}
echo "Deleted replica indices.\n";

Clear records from an index in the Algolia dashboard

If you only want to delete (clear) the records from an index, keeping the index configuration, follow these steps:

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

    Select your Algolia application and index

  4. Select Manage index > Clear.

    Delete all records from an index, keeping its configuration

  5. Type CLEAR to confirm and click Clear.

Clear records from an index with the API

To remove only the records from the index, while keeping the settings, synonyms, and rules, use one of the following methods:

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

// You need an API key with `deleteIndex` permissions
$client = SearchClient::create('YourApplicationID', 'YourAPIKey');

$index = $client->initIndex('YourIndexName');
$index->clearObjects();
echo "Deleted records.\n";
Did you find this page helpful?