# How many Aliases can an Index have?

**URL:** <https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953>\
**Category:** Elasticsearch\
**Created:** [February 20, 2023, 10:29am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953 "2023-02-20T10:29:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbart01](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tbart01](https://discuss.elastic.co/u/tbart01)\
**Post date:** [February 20, 2023, 10:29am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/1 "2023-02-20T10:29:46Z")

</div>

We have an index with some 250,000 aliases, and rapidly growing. Are there any known limits that we should be aware of? We were not able to find any concrete information searching the web/documentation.

Lately, we've noticed that it is taking longer to add new aliases to the index. We have also noticed an instance of "_failed to process cluster event (index-aliases) within 30s_", but this only happened one time so far.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 21, 2023, 3:03am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/2 "2023-02-21T03:03:14Z")

</div>

Welcome to our community! 😃

> [@tbart01](#):
>
> We have an index with some 250,000 aliases

> [@tbart01](#):
>
> Lately, we've noticed that it is taking longer to add new aliases to the index. We have also noticed an instance of "_failed to process cluster event (index-aliases) within 30s_"

Because each alias addition needs to update the cluster state, and I have never seen of anyone with that many so it's not a surprise it's slow!

Why are you taking this approach?

---

<div class="post-metadata">

**Author:** ![tbart01](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tbart01](https://discuss.elastic.co/u/tbart01)\
**Post date:** [February 21, 2023, 8:01am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/3 "2023-02-21T08:01:17Z")

</div>

> [@warkolm](#):
>
> Welcome to our community! 😃

Thanks!

> [@warkolm](#):
>
> Because each alias addition needs to update the cluster state, and I have never seen of anyone with that many so it's not a surprise it's slow!

Thanks for confirming our suspicions.

> [@warkolm](#):
>
> Why are you taking this approach?

Without going into unnecessary detail, we are using aliases for ease of searching by making use of prefix wildcards on the alias name during search.

Due to the above issues, we are now looking into replacing the alias filters with search-time query filters; we just hope that we do not hit some sort of query limitation, as we will be requiring up to 300 filters to be added onto the query.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 21, 2023, 8:18am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/4 "2023-02-21T08:18:48Z")

</div>

300 is better than 250000, so I would suggest that's a good start.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 21, 2023, 8:19am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/5 "2023-02-21T08:19:11Z")

</div>

> [@tbart01](#):
>
> Due to the above issues, we are now looking into replacing the alias filters with search-time query filters; we just hope that we do not hit some sort of query limitation, as we will be requiring up to 300 filters to be added onto the query.

Queries with 300 clauses will also add overhead. It may be useful if you could explain a bit about your data and the problem you are trying to solve using these immense number of aliases and additional query clauses. Maybe someone can provide an alternate and more efficient approach.

---

<div class="post-metadata">

**Author:** ![tbart01](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tbart01](https://discuss.elastic.co/u/tbart01)\
**Post date:** [February 21, 2023, 8:38am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/6 "2023-02-21T08:38:42Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> It may be useful if you could explain a bit about your data and the problem you are trying to solve using these immense number of aliases and additional query clauses. Maybe someone can provide an alternate and more efficient approach.

Here's a very high level of what we have:

We have around 200,000 unique schemas, and 7,000 "users", but not all users have access to all schemas.

Originally, we had an index per schema, but we quickly ran into issues as indices grew. We scrapped everything and decided on a "generic" schema which can handle most (as we have more than a single index to share the load of schemas) schemas.

Since all users are now searching against a handful of indices instead of 200,000, we decided to employ alias filters for a few reasons:

- shorten ES query
- convenient access to a specific user's data

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 21, 2023, 9:28am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/7 "2023-02-21T09:28:32Z")

</div>

What is the minimum, maximum and average number of documents per schema?

What is the minimum, maximum and average number of schemas a user has access to?

---

<div class="post-metadata">

**Author:** ![tbart01](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tbart01](https://discuss.elastic.co/u/tbart01)\
**Post date:** [February 21, 2023, 10:04am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/8 "2023-02-21T10:04:24Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> What is the minimum, maximum and average number of documents per schema?

10, 10 million, 500,000, respectively.

> [@Christian\_Dahlqvist](#):
>
> What is the minimum, maximum and average number of schemas a user has access to?

So, "user" is a placeholder for what is actually out there. We have "clients", and those clients can have tens of thousands of end-users. A single end-user can have access to up to 300 schemas, and thus we would create the query for that specific user. So, the answer to your question is 1, 300, 50, respectively.

---

<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:** [March 21, 2023, 10:04am UTC](https://discuss.elastic.co/t/how-many-aliases-can-an-index-have/325953/9 "2023-03-21T10:04:30Z")

</div>

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