In Elasticsearch, an index is regarded as dangling if the index data is absent from the current cluster state. This article will show you how to use the Elasticsearch dangling APIs to perform various actions.
Elasticsearch List Dangling Indices
Let’s start by learning how to show the dangling indices within a given cluster. Then, we can use the list dangling indices API.
The request syntax is as shown:
This should list all the dangling indices in the cluster. Keep in mind that this API requires manage privileges on the target cluster.
An example is shown below:
The resulting output is as shown:
"_nodes": {
"total": 3,
"successful": 3,
"failed": 0
},
"cluster_name": "22df4b961f964d52a58b41808c667f44",
"dangling_indices": [
{
"index_name": "netflix",
"index_uuid": "C69p6sDMRJCqDjB06c9fNQ",
"creation_date": 1662183674763,
"node_ids": [
"ZgSuHyYDSUSDMxcJRXN0LA"
]
}
]
}
Elasticsearch Delete Dangling Index
You can use the Delete dangling index API to remove a dangling index from the cluster.
The request syntax is as shown:
The request requires the UUID of the index on which to delete. This UUID value is shown in the list dangling API, as illustrated above.
An example is shown below:
The request above should remove the dangling index with the specified UUID.
Conclusion
In this article, you learned how to view the available dangling indices in your cluster. You also learned how to remove a dangling index from a cluster using the Elasticsearch built-in APIs.