Multitenancy

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

  • 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?

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

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

You update your code to handle it.