# Index name prefix/suffix

**URL:** <https://discuss.elastic.co/t/index-name-prefix-suffix/71348>\
**Category:** Elasticsearch\
**Created:** [January 12, 2017, 9:37am UTC](https://discuss.elastic.co/t/index-name-prefix-suffix/71348 "2017-01-12T09:37:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olee/32/14502_2.png) [@olee](https://discuss.elastic.co/u/olee)\
**Post date:** [January 12, 2017, 9:37am UTC](https://discuss.elastic.co/t/index-name-prefix-suffix/71348/1 "2017-01-12T09:37:09Z")

</div>

Hi, I would like to use NEST and have my index names automatically prefixed with something like "dev\_" for handling different environments.  
Is there a way to do this directly in NEST through some kind of hook or connection handler etc.?

---

<div class="post-metadata">

**Author:** ![Martijn\_Laarman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martijn_laarman/32/4410_2.png) [@Martijn\_Laarman](https://discuss.elastic.co/u/Martijn_Laarman)\
**Post date:** [January 13, 2017, 10:06am UTC](https://discuss.elastic.co/t/index-name-prefix-suffix/71348/2 "2017-01-13T10:06:16Z")

</div>

You can use the following:

```auto
var settings = new ConnectionSettings()
   .InferMappingFor<Project>(m=>m
   	.IndexName(GetEnvironmentPrefix() + "project")
   ); 

```

`GetEnvironmentPrefix()` would yield the correct prefix based on where its running.

---

<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:** [February 10, 2017, 10:06am UTC](https://discuss.elastic.co/t/index-name-prefix-suffix/71348/3 "2017-02-10T10:06:56Z")

</div>

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