# Is it possible to auto increment documents as they are indexed?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-auto-increment-documents-as-they-are-indexed/300887>\
**Category:** Elasticsearch\
**Created:** [March 28, 2022, 7:12pm UTC](https://discuss.elastic.co/t/is-it-possible-to-auto-increment-documents-as-they-are-indexed/300887 "2022-03-28T19:12:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Dominic\_Ramp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_dominic_ramp/32/103606_2.png) [@Matthew\_Dominic\_Ramp](https://discuss.elastic.co/u/Matthew_Dominic_Ramp)\
**Post date:** [March 28, 2022, 7:12pm UTC](https://discuss.elastic.co/t/is-it-possible-to-auto-increment-documents-as-they-are-indexed/300887/1 "2022-03-28T19:12:38Z")

</div>

Context:

- I am using the bulk API to index several documents into an index

- I would like to auto increment a field, 'y', present in the documents, which would tally the order in which documents are indexed. (I know i can do this using timestamp but am seeking alternatives)  
So the first document will have y=1 and in a future bulk import, the nth document will have y=n.

Is this possible?

(The reason why I am not using timestamp is because there is a chance that more than one document may have the same timestamp)

---

<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:** [March 28, 2022, 7:56pm UTC](https://discuss.elastic.co/t/is-it-possible-to-auto-increment-documents-as-they-are-indexed/300887/2 "2022-03-28T19:56:48Z")

</div>

That is something you will need to handle and assign yourself before indexing the documents.

---

<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:** [April 25, 2022, 7:57pm UTC](https://discuss.elastic.co/t/is-it-possible-to-auto-increment-documents-as-they-are-indexed/300887/3 "2022-04-25T19:57:08Z")

</div>

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