# How to Delete an Index in Elasticsearch: Efficient Removal from a Running Cluster

> Learn the most efficient way to delete an index in Elasticsearch using the Delete Index API. Remove index data and metadata quickly from your running cluster.

- Repository: [elastic/elasticsearch](https://github.com/elastic/elasticsearch)
- Tags: how-to-guide
- Published: 2026-02-20

---

**The most efficient way to delete an index in Elasticsearch is to issue a single DELETE request to the Delete Index API, which triggers TransportDeleteIndexAction to synchronously remove the index metadata from the cluster state and asynchronously delete all underlying shard files across every data node.**

Removing data from a running Elasticsearch cluster requires careful coordination between the master node and data nodes to ensure metadata consistency and complete storage reclamation. In the elastic/elasticsearch source code, the delete index Elasticsearch operation is handled by dedicated transport actions that orchestrate cluster-wide cleanup without manual intervention. This approach ensures that all shard data, replicas, and associated system indices are permanently removed through a single coordinated request.

## How the Delete Index API Works Internally

### REST Layer: RestDeleteIndexAction

The entry point for any deletion request is `RestDeleteIndexAction` located in [`server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexAction.java`](https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestDeleteIndexAction.java). This handler parses incoming HTTP DELETE requests, validates the target index name(s), and constructs a `DeleteIndexRequest` that flows into the transport layer. It supports wildcard patterns, comma-separated indices, and query parameters like `ignore_unavailable` to control error handling.

### Master Node Coordination: TransportDeleteIndexAction

The core orchestration logic resides in `TransportDeleteIndexAction` at [`server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java`](https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java). Running on the elected master node, this transport action atomically updates the cluster state to mark the index as removed, preventing any new search or indexing operations. It then dispatches deletion events to all data nodes holding primary or replica shards for that index.

### Data Node Cleanup: CompositeIndexFoldersDeletionListener

On each data node, the `CompositeIndexFoldersDeletionListener` in [`server/src/main/java/org/elasticsearch/indices/store/CompositeIndexFoldersDeletionListener.java`](https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/indices/store/CompositeIndexFoldersDeletionListener.java) listens for index deletion events from the master. This component triggers the physical removal of shard directories from disk and coordinates with `SystemIndices` in [`server/src/main/java/org/elasticsearch/indices/SystemIndices.java`](https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/indices/SystemIndices.java) to clean up any associated system-index artifacts.

## Step-by-Step Deletion Execution Flow

When you delete index Elasticsearch data, the following coordinated sequence occurs:

1. **REST Request Parsing**: `RestDeleteIndexAction` receives the DELETE request and creates a `DeleteIndexRequest` object containing the target indices and options.

2. **Client Delegation**: The `IndicesAdminClient` interface in [`server/src/main/java/org/elasticsearch/client/internal/IndicesAdminClient.java`](https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/client/internal/IndicesAdminClient.java) forwards the request via the internal transport service to the master node.

3. **Cluster State Update**: `TransportDeleteIndexAction` synchronously updates the cluster state to remove the index metadata, immediately making the index unavailable for cluster operations.

4. **Asynchronous File Removal**: Data nodes receive the deletion event and `CompositeIndexFoldersDeletionListener` initiates background deletion of physical shard folders, freeing disk space without blocking the API response.

5. **Acknowledgment**: Once all nodes confirm metadata removal, the transport action returns an `AcknowledgedResponse` to the REST handler, resulting in a 200 OK status (or 404 if the index did not exist and `ignore_unavailable` is false).

## Code Examples for Deleting Indices

### Using the REST API

The simplest method uses curl to target the Delete Index API directly:

```bash

# Delete a single index

curl -X DELETE "http://localhost:9200/my-index?pretty"

# Delete multiple indices using wildcards

curl -X DELETE "http://localhost:9200/logs-2023.*?pretty"

```

These requests route through `RestDeleteIndexAction` and remove all shard data for the specified indices.

### Using the Java High-Level Client

For Java applications, use the `RestHighLevelClient` to invoke `IndicesAdminClient.delete()`:

```java
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.DeleteIndexRequest;

// client is a configured RestHighLevelClient
DeleteIndexRequest request = new DeleteIndexRequest("my-index");
client.indices().delete(request, RequestOptions.DEFAULT);

```

This client method internally constructs the same `DeleteIndexRequest` sent to `TransportDeleteIndexAction`.

### Using the Low-Level Transport API

For internal node operations or custom plugins:

```java
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction;

// client is an internal node client
DeleteIndexRequest request = new DeleteIndexRequest("my-index");
client.execute(TransportDeleteIndexAction.TYPE, request,
    ActionListener.wrap(
        r -> System.out.println("Deleted successfully"),
        e -> e.printStackTrace()));

```

This snippet demonstrates the exact transport call that high-level clients ultimately use.

## Why This Is the Most Efficient Approach

- **Single Coordinated Request**: One API call removes the index, all its replicas, and associated system indices without requiring manual cleanup of individual shards.
- **Atomic Metadata Removal**: The master node ensures the index is immediately removed from the global cluster state, preventing stale references or partial deletions.
- **Non-Blocking File Deletion**: Physical shard files are deleted asynchronously via `CompositeIndexFoldersDeletionListener`, allowing the API to return quickly while disk space reclaims in the background.
- **Built-in Safety Mechanisms**: The request respects `ignore_unavailable` flags, destructive operation settings, and index-level security privileges enforced by `TransportDeleteIndexAction`.

## Summary

- Issue a single `DELETE /<index>` request to remove an index and all its data from a running cluster.
- The operation flows through `RestDeleteIndexAction` → `IndicesAdminClient` → `TransportDeleteIndexAction` → `CompositeIndexFoldersDeletionListener`.
- File deletion occurs asynchronously on data nodes after the master updates the cluster state.
- Use `ignore_unavailable=true` to prevent errors when deleting indices that may not exist.

## Frequently Asked Questions

### Does deleting an index in Elasticsearch immediately free disk space?

Disk space is reclaimed as soon as the `CompositeIndexFoldersDeletionListener` completes the asynchronous deletion of shard directories on each data node. This typically happens within seconds of the API returning a 200 OK response, though the exact timing depends on file system I/O and the number of shards being deleted.

### Can I delete multiple indices at once in Elasticsearch?

Yes, you can delete multiple indices using wildcards, comma-separated lists, or date math expressions in the index name. The `RestDeleteIndexAction` processes these patterns and creates a single `DeleteIndexRequest` that targets all matching indices atomically through the same `TransportDeleteIndexAction` workflow.

### What happens if I try to delete an index that doesn't exist?

By default, Elasticsearch returns a 404 Not Found error. However, you can add the `ignore_unavailable=true` query parameter to suppress this error and return a successful acknowledgment even if the index is missing. The `TransportDeleteIndexAction` checks for this flag before processing the cluster state update.

### Is it safe to delete an index on a production Elasticsearch cluster?

Yes, provided you have proper backups or snapshots stored externally. The deletion is coordinated through the master node to ensure consistency across the cluster, and the operation respects index-level security permissions. However, deletion is irreversible unless you restore from a snapshot, as `SystemIndices` and `CompositeIndexFoldersDeletionListener` permanently remove all associated metadata and data files.