Aliasing a real index pattern


#1

lets say I have an actual, real index pattern foo-*. then i create another real index pattern v2-foo-*. now i create an alias that looks something like this:
{ "actions": [ { "add": { "index": "v2-foo-*", "alias": "foo-*" } } ] }

Lets just say that the pattern invoked by -* is simply a pattern for the date (eg, 2015.12.04).
So say I have these two sets of indexes:
foo-2015.12.01
foo-2015.12.02
foo-2015.12.03
foo-2015.12.04

v2-foo-2015.12.01
v2-foo-2015.12.02
v2-foo-2015.12.03
v2-foo-2015.12.04

Now, I want to be able to delete all of the old foo-* indices. Is there anyway of doing this, other than having to reference each one of them individually?


(David Pilato) #2

Is the alias creation request accepted by elasticsearch ?


#3

Sorry, I didn't write the question out properly. I have since edited. thanks


(Nik Everett) #4

curl -XDELETE 'localhost:9200/foo-*' should do it though I tend to not use wildcards in deletes because I fear mistyping things. I suggest full paranoia: test it locally before you run it on real stuff. Make sure it only deletes what you want and then copy the command where you want to run it.


(Nik Everett) #5

https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html


#6

think there might be confusion here. as I have pointed out, foo-* is aliased to v2-foo-*.. so running DELETE foo-* deletes all v2-foo-* indices. I just tested it.


(Nik Everett) #7

@dadoonet, I dunno if its ok that we resolve the DELETEs through the aliases. That seems a bit too much.

@treehouse, I'd just delete each index individually. I'd pretty much do that all the time anyway, but I'd certainly do that given when you've mentioned here.


#8

yep makes sense, thanks for the tip.


(system) #9