Elastic Search

Elasticsearch Delete Dangling Index

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:

GET /_dangling

 
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:

curl -XGET "http://localhost:9200/_dangling/" -H "kbn-xsrf: reporting"

 
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:

DELETE /_dangling/<index-uuid>?accept_data_loss=true

 
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:

curl -XDELETE "http://localhost:9200/_dangling/C69p6sDMRJCqDjB06c9fNQ?accept_data_loss=true" -H "kbn-xsrf: reporting"

 
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.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list