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

For deleting indices, you have two options:

  • Deleting everything.

    Removes the entire index with records, rules, settings, and synonyms from your Algolia application.

  • Delete just the records.

    Only deletes the records, keeping rules, settings, and synonyms.

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

Delete indices

If you delete an index, all records, rules, settings, and synonyms will be removed from your Algolia application. The associated analytics data won’t be deleted.

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 in the Enterprise pricing plan add-on.

Indices with replicas

In the dashboard, or using the API, you can’t delete a replica index directly. You must first unlink it from the primary index.

If you delete a primary index, its replica indices become regular, independent indices.

You can delete replica indices with the Algolia CLI’s algolia indices delete command. It handles the unlinking for you.

Delete indices in the Algolia 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
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;

var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));

var response = await client.DeleteIndexAsync("ALGOLIA_INDEX_NAME");

Delete multiple indices

To delete more than one index:

  1. Use listIndices (API client)
  2. Use multipleBatch 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace Algolia;

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Json;
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;

class DeleteMultipleIndices
{
  async Task Main(string[] args)
  {
    // You need an API key with `deleteIndex`
    var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));

    // List all indices
    var indices = await client.ListIndicesAsync();

    // Primary indices don't have a `primary` key
    var primaryIndices = indices.Items.Where(item => item.Primary == null).ToList();
    var replicaIndices = indices.Items.Where(item => item.Primary != null).ToList();

    // Delete primary indices first
    if (primaryIndices.Count > 0)
    {
      var requests = primaryIndices
        .Select(index => new MultipleBatchRequest(Search.Models.Search.Action.Delete, index.Name))
        .ToList();
      await client.MultipleBatchAsync(new BatchParams { Requests = requests });
      Console.WriteLine("Deleted primary indices.");
    }

    // Now, delete replica indices
    if (replicaIndices.Count > 0)
    {
      var requests = replicaIndices
        .Select(index => new MultipleBatchRequest(Search.Models.Search.Action.Delete, index.Name))
        .ToList();
      await client.MultipleBatchAsync(new BatchParams { Requests = requests });
      Console.WriteLine("Deleted replica indices.");
    }
  }
}

Consider using the Algolia CLI. Its algolia indices delete command lets you delete multiple indices and handles deleting replica indices for you.

Clear indices

If you clear an index, you just delete the records, but keep the settings, synonyms, and rules. This is helpful if you want to reindex your records without changing the rest.

Delete all records from an index in the Algolia 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 > Clear.

    Delete all records from an index, keeping its configuration

  5. Type CLEAR to confirm and click Clear.

Delete all records from an index with the API

To clear an index and delete all records, use on of these methods:

1
2
3
4
5
6
7
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;

var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));

var response = await client.ClearObjectsAsync("ALGOLIA_INDEX_NAME");
Did you find this page helpful?