How to delete an index on Elasticsearch?

Article ID:228366568
1 minute readKnowledge base

Issue

How to delete an index on Elasticsearch

Environment

  • CloudBees Jenkins Operations Center

Resolution

In your web browser navigate to elasticsearchInstance:PORT/_aliases?pretty=1 .You should see output similar to what is shown in the screenshot below:

Make a note of the specific index or indices you would like to delete.

To delete a specific index you will need to run: curl -XDELETE https://localhost:9200/indexName/

To delete all occurrences of a specific index you can run: curl -XDELETE https://localhost:9200/indexName*/

The curl commands are based on the steps documented in the Elasticsearch documentation.

For example, using the build- indexes shown in the screenshot above the following curl commands will delete a specific index or all of the build- indexes:

To delete a builds-20160919 index you will need to run: curl -XDELETE https://elasticsearchInstance:PORT/builds-20160919/

To delete all occurrences of a builds- indexes you can run: curl -XDELETE https://elasticsearchInstance:PORT/builds-*/

Running the curl commands should produce output similar to the following:

C:\Windows\System32>curl -XDELETE https://localhost:9200/builds-20160919/
{"acknowledged":true}
C:\Windows\System32>curl -XDELETE https://localhost:9200/builds-20160916/
{"acknowledged":true}
C:\Windows\System32>curl -XDELETE https://localhost:9200/builds-*/
{"acknowledged":true}

If necessary the builds indexes can be recreated by setting up a cluster operation on CJOC to reindex the jobs on Jenkins as documented in the "Reindexing for CloudBees Jenkins Analytics" section here .