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 Delete only records from an index on this page.

Before you delete an index, you may want to create a backup by exporting your index.

Deleting an index doesn’t affect analytics data.

Deleting 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 from the Algolia dashboard

To delete an index from the dashboard:

  1. Go to the Algolia dashboard and select your index from the Index menu.
  2. Select Manage index > Delete.

    Delete an index from the Algolia dashboard

  3. Type DELETE to confirm and click Delete.

Delete indices with the API

To delete an index, use the deleteIndex method.

1
$index->delete();

You can only delete one index at a time.

Delete multiple indices

To delete more than one index, use listIndices to get an application’s indices and then use the multipleBatch method to delete multiple indices from a single API call. If you want to delete replica indices, you have to delete their primary indices first.

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

// 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 using the Algolia dashboard

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

  1. Go to the Algolia dashboard and select your index from the Index menu.

    Delete all records from an index, keeping its configuration

  2. Type CLEAR to confirm and click Clear.

Clear records from an index using the API

To only remove records from the index, use the clearObjects method. Settings, synonyms, and Rules will be kept.

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

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