# Aliasing a real index pattern

**URL:** <https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115>\
**Category:** Elasticsearch\
**Created:** [December 2, 2015, 3:20am UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115 "2015-12-02T03:20:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [December 2, 2015, 3:20am UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/1 "2015-12-02T03:20:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 2, 2015, 6:09am UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/2 "2015-12-02T06:09:44Z")

</div>

Is the alias creation request accepted by elasticsearch ?

---

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [December 4, 2015, 1:42am UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/3 "2015-12-04T01:42:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 4, 2015, 2:57pm UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/4 "2015-12-04T14:57:51Z")

</div>

> [@treehouse](#):
>
> 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?

`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.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 4, 2015, 2:58pm UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/5 "2015-12-04T14:58:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [December 6, 2015, 9:07pm UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/6 "2015-12-06T21:07:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 7, 2015, 6:27pm UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/7 "2015-12-07T18:27:19Z")

</div>

> [@treehouse](#):
>
> 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.

@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.

---

<div class="post-metadata">

**Author:** ![treehouse](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@treehouse](https://discuss.elastic.co/u/treehouse)\
**Post date:** [December 7, 2015, 10:04pm UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/8 "2015-12-07T22:04:42Z")

</div>

yep makes sense, thanks for the tip.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:32pm UTC](https://discuss.elastic.co/t/aliasing-a-real-index-pattern/36115/9 "2017-07-05T23:32:57Z")

</div>


