Skip to main content
You can either delete the entire index or only its records: Before you delete an index, create a backup by exporting your index.

Delete indices

Deleting an index removes all records, rules, settings, and synonyms from your Algolia application. Algolia retains the associated analytics data even after index deletion.
If you delete an index by mistake, the Algolia support team might be able to restore it, but recovery isn’t guaranteed. The Enterprise pricing plan add-on.

Indices with replicas

You can’t delete a replica index directly. First, unlink it from its primary index. If you delete a primary index, its replica indices become regular, independent indices.
To delete replica indices directly, use the Algolia CLI algolia indices delete command: it automatically un-links them.

Delete indices in the Algolia dashboard

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Manage index > Delete.
  5. Type DELETE to confirm and click Delete.

Delete indices with the API

Delete an index with either of the following:
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 several indices with a single request.
To delete replica indices, you must first delete their primary indices.
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.");
    }
  }
}
The multipleBatch method expects a list of operations. Don’t wrap these operations in a requests property: API clients do this automatically. If you pass something like { requests: [...] }, you’ll get an error such as: “Requests attribute must be an array.”

Clear indices

Clearing an index deletes only the records. Use this option to reindex records but keep your settings, synonyms, and rules.

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 Search.
  3. Select your Algolia index.
  4. Select Manage index > Clear.
  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 either of the following:
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");
I