# Details/Insights on how switching the index behind an alias works

**URL:** <https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146>\
**Category:** Elasticsearch\
**Created:** [October 7, 2021, 2:22pm UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146 "2021-10-07T14:22:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nexonus](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nexonus](https://discuss.elastic.co/u/Nexonus)\
**Post date:** [October 7, 2021, 2:22pm UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146/1 "2021-10-07T14:22:45Z")

</div>

I would like to get some insight information about how an alias switch works.

### Our scenario

We observed a scenario in our cluster (only 3 nodes) where we did an alias switch and still queried the old data from the old index for a couple of minutes before we got the new one. There was no load on the cluster during that time. Our indices have about 200k documents and are roughly 200 MB in size. Each index has one primary shard and two replicas.  
We switched the index behind the alias to the newly build index and found out that we only got the new data after about 1-2 minutes.

Our theory is that the alias was not immediate and took some time (for whatever reason).

Can somebody explain in a bit more detail what happens when the alias is switched to a new index?

---

<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:** [October 7, 2021, 3:17pm UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146/2 "2021-10-07T15:17:03Z")

</div>

More or less, a new index is created in the cluster state. The alias is changed in the cluster state.

The cluster state is broadcasted to the nodes.

What is the output of:

```auto
GET /
GET /_cat/nodes?v
GET /_cat/health?v
GET /_cat/indices?v

```

If some outputs are too big, please share them on [gist.github.com](http://gist.github.com) and link them here.

---

<div class="post-metadata">

**Author:** ![Nexonus](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nexonus](https://discuss.elastic.co/u/Nexonus)\
**Post date:** [October 11, 2021, 8:30am UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146/3 "2021-10-11T08:30:10Z")

</div>

Hey David,

here is the requested output:

> <https://gist.github.com/moritzluedtke/1f41840237524ab4b296b9c429c7f628>

I would like to add that this scenario happens very rarely in our cluster. And sadly we cannot replicate it. So this is very hard to debug.

---

<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:** [October 11, 2021, 12:04pm UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146/4 "2021-10-11T12:04:26Z")

</div>

I don't see anything wrong here.  
I have no idea why you are seeing such a thing. 😔

---

<div class="post-metadata">

**Author:** ![Nexonus](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Nexonus](https://discuss.elastic.co/u/Nexonus)\
**Post date:** [October 11, 2021, 12:42pm UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146/5 "2021-10-11T12:42:44Z")

</div>

Thanks for taking a look at this David!

We will monitor our cluster closely and see if this happens again. Maybe we can share some more information when it happens again.

---

<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:** [November 8, 2021, 12:42pm UTC](https://discuss.elastic.co/t/details-insights-on-how-switching-the-index-behind-an-alias-works/286146/6 "2021-11-08T12:42:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
