# How to create autoincremented Id (integer) in Elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-create-autoincremented-id-integer-in-elasticsearch/276108>\
**Category:** Elasticsearch\
**Created:** [June 16, 2021, 8:42am UTC](https://discuss.elastic.co/t/how-to-create-autoincremented-id-integer-in-elasticsearch/276108 "2021-06-16T08:42:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeusfsx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeusfsx/32/59433_2.png) [@zeusfsx](https://discuss.elastic.co/u/zeusfsx)\
**Post date:** [June 16, 2021, 8:42am UTC](https://discuss.elastic.co/t/how-to-create-autoincremented-id-integer-in-elasticsearch/276108/1 "2021-06-16T08:42:41Z")

</div>

Hi, I`m interested in how to create autoincremented Id (integer) in Elasticsearch, or maybe someone knows how to create autoincrement field with the script when added a new document into the index?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 16, 2021, 8:53am UTC](https://discuss.elastic.co/t/how-to-create-autoincremented-id-integer-in-elasticsearch/276108/2 "2021-06-16T08:53:06Z")

</div>

That is not supported as it is impossible to do so efficiently in a distributed system like Elasticsearch.

If you want that type of identifier you will need to set it yourself before sending the data to Elasticsearch. Be aware this is likely to introduce bottlenecks unless you are ingesting data at a very small scale.

---

<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 14, 2021, 8:53am UTC](https://discuss.elastic.co/t/how-to-create-autoincremented-id-integer-in-elasticsearch/276108/3 "2021-07-14T08:53:54Z")

</div>

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