# How to namespace indexes - Automatic not Manual

**URL:** https://discuss.elastic.co/t/how-to-namespace-indexes-automatic-not-manual/347886
**Category:** Elasticsearch
**Created:** [November 23, 2023, 7:16pm UTC](https://discuss.elastic.co/t/how-to-namespace-indexes-automatic-not-manual/347886 "2023-11-23T19:16:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander\_Mills](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexander_mills/32/127987_2.png) [@Alexander\_Mills](https://discuss.elastic.co/u/Alexander_Mills)
#### Post date: [November 23, 2023, 7:16pm UTC](https://discuss.elastic.co/t/how-to-namespace-indexes-automatic-not-manual/347886/1 "2023-11-23T19:16:31Z")

</div>

> <https://github.com/elastic/elasticsearch/issues/102503>
>
> \### Description
> 
> Mongo has namespacing via different databases on the same db se…rver
> RabbitMQ has namespacing via different exhanges
> etc etc
> 
> but with ES, there is no automatic namespacing feature, instead ChatCPT suggests
> 
> \> Yes, you can namespace Elasticsearch for different environments using a few different strategies:
> \> 
> \> 1. \*\*Index Naming Conventions\*\*: Use distinct index names for each environment. For instance, prefix your index names with the environment like \`dev-\`, \`staging-\`, \`prod-\`.
> \> 
> \> 2. \*\*Separate Clusters\*\*: Deploy separate Elasticsearch clusters for each environment. This is a more robust approach, ensuring complete isolation between environments.
> \> 
> \> 3. \*\*Index Aliases\*\*: Use index aliases to abstract the actual index names. This way, you can have the same alias pointing to different indexes in different environments.
> \> 
> \> 4. \*\*Document-Level Routing\*\*: If you need to use the same index, consider using custom routing to separate documents from different environments, though this is less common and can complicate maintenance and scaling.
> \> 
> \> 5. \*\*Access Control\*\*: Implement access control to limit access to data based on the environment, using features like X-Pack security in Elasticsearch.
> \> 
> \> Each of these methods has its pros and cons, and the choice depends on factors like the scale of your operations, the level of isolation needed, and resource availability.
> 
> 
> I am looking for a way to shard/namespace an ES instance

Mongo has namespacing via different databases on the same db server

RabbitMQ has namespacing via different exhanges

How can I automatically namespace indices with Elastic without manually namespacing keys with prod-x and stage-x etc

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [November 23, 2023, 7:33pm UTC](https://discuss.elastic.co/t/how-to-namespace-indexes-automatic-not-manual/347886/2 "2023-11-23T19:33:31Z")

</div>

> [@Alexander\_Mills](#):
>
> How can I automatically namespace indices with Elastic without manually namespacing keys with prod-x and stage-x etc

Can you provide some context of what you mean with this?

Elasticsearch is a different tool, it does not have the concept of namespace, it has indexes, so it is not clear what you want to achieve.

---

<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: [December 21, 2023, 7:34pm UTC](https://discuss.elastic.co/t/how-to-namespace-indexes-automatic-not-manual/347886/3 "2023-12-21T19:34:20Z")

</div>

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