Viewing and Deleting elasticsearch indexes

Generally I find it easiest to view the indexes on box by sending a command with curl.

for example this will list every index:

curl http://localhost:9200/_aliases

Unfortunately it lists it in a big block of text, to see it formatted in a nicer way try:

curl http://localhost:9200/_aliases?pretty=1

Now lets say for example you want to delete just one index. That can also easily be done with curl.

e.g.

curl -XDELETE localhost:9200/2015.06.01

Where everything after the / is your index name.  If this works you should have a response from the server of:

{“acknowledged”:true}

If you mistype or the index is already gone you might see this returned:

{“error”:”IndexMissingException[[bacon] missing]”,”status”:404}

Check the name issues and maybe list all the indexes again so you can be sure they aren’t already gone or you have the wrong name.

You can also use wildcards to delete similarly named indexes. So if for example I wanted to delete all the June indexes I could issue this command:

curl -XDELETE localhost:9200/2015.06*

One gotcha with the wildcard is that you always seem to get a response of {“acknowledged”:true} even if you give a name and wildcard that matches nothing, so make sure you have the right name and to check the indexes after issuing the command.