# Multitenancy

**URL:** <https://discuss.elastic.co/t/multitenancy/330357>\
**Category:** Elasticsearch\
**Created:** [April 20, 2023, 6:47am UTC](https://discuss.elastic.co/t/multitenancy/330357 "2023-04-20T06:47:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [April 20, 2023, 6:47am UTC](https://discuss.elastic.co/t/multitenancy/330357/1 "2023-04-20T06:47:01Z")

</div>

I want to set up a multitenant elasticsearch cluster.  
say I have 😑

- 100 GB index (tenant 1)
- 150 GB index (tenant 2)
- 20 GB (tenant 3)
- 30 GB (tenant 4)

How could I set up multitenancy? how do I route the documents to the specific index..  
say I want tenant 1 in indexA, tenant 2 in indexB and club tenant 3 and 4 in indexC .

Do I need a routing algorithm or hashing done prior to the documents getting ingested? Is there a sample code I could check?

---

<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:** [April 20, 2023, 6:54am UTC](https://discuss.elastic.co/t/multitenancy/330357/2 "2023-04-20T06:54:39Z")

</div>

You tell your indexing code which index it needs to based on the customer.

---

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [April 20, 2023, 8:20am UTC](https://discuss.elastic.co/t/multitenancy/330357/3 "2023-04-20T08:20:05Z")

</div>

what if there is a new tenant .. how do I assign it to one of the available indices?

---

<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:** [April 20, 2023, 9:20pm UTC](https://discuss.elastic.co/t/multitenancy/330357/4 "2023-04-20T21:20:15Z")

</div>

You update your code to handle it.

---

<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:** [May 18, 2023, 9:20pm UTC](https://discuss.elastic.co/t/multitenancy/330357/5 "2023-05-18T21:20:39Z")

</div>

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