# Elastic/NEST 2.0+ how to avoid some characters in the auto-generated Id "\_id"?

**URL:** <https://discuss.elastic.co/t/elastic-nest-2-0-how-to-avoid-some-characters-in-the-auto-generated-id--id/58439>\
**Category:** Elasticsearch\
**Created:** [August 19, 2016, 9:36am UTC](https://discuss.elastic.co/t/elastic-nest-2-0-how-to-avoid-some-characters-in-the-auto-generated-id--id/58439 "2016-08-19T09:36:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PzDev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pzdev/32/11474_2.png) [@PzDev](https://discuss.elastic.co/u/PzDev)\
**Post date:** [August 19, 2016, 9:36am UTC](https://discuss.elastic.co/t/elastic-nest-2-0-how-to-avoid-some-characters-in-the-auto-generated-id--id/58439/1 "2016-08-19T09:36:21Z")

</div>

When indexing a new document with an auto-generated id there is some characters in the Id (\_id) I would like to avoid.  
Sample Id : AVaeUlLX\_DM3y2eId2rf  
Typically I don't want \_ or - characters.  
Is it possible to setup this somewhere (with a pattern +/- style) ?  
Or, is this feature can be possible and added in future ?

( At the moment I've a nasty trick to avoid the problem by checking the Id of the document. I delete it if it contains characters I don't want then re-indexing, ugly loop yes but now this is how it works for me. )

Any help or idea appreciated.

---

<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:** [July 5, 2017, 10:26pm UTC](https://discuss.elastic.co/t/elastic-nest-2-0-how-to-avoid-some-characters-in-the-auto-generated-id--id/58439/2 "2017-07-05T22:26:41Z")

</div>


