How to delete an index on elasticsearch

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 screen shot 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 http://localhost:9200/indexName/

To delete all occurrences of a specific index you can run: curl -XDELETE http://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 screen shot 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 http://elasticsearchInstance:PORT/builds-20160919/

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

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

  C:\Windows\System32>curl -XDELETE http://localhost:9200/builds-20160919/
  {"acknowledged":true}
  C:\Windows\System32>curl -XDELETE http://localhost:9200/builds-20160916/
  {"acknowledged":true}
  C:\Windows\System32>curl -XDELETE http://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 .

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.