# Identity/Autonumber ID's

**URL:** <https://discuss.elastic.co/t/identity-autonumber-ids/7973>\
**Category:** Elasticsearch\
**Created:** [June 4, 2012, 11:48pm UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973 "2012-06-04T23:48:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Duarte\_Figuei](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@Daniel\_Duarte\_Figuei](https://discuss.elastic.co/u/Daniel_Duarte_Figuei)\
**Post date:** [June 4, 2012, 11:48pm UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/1 "2012-06-04T23:48:34Z")

</div>

Is there a way of using identity/autonumber ids in ES similar to a  
traditional relational database?  
I have an index called post\_index with "post" documents and I want to  
assign unique numeric ids to them (1, 2, 3..). Is there an easy way of  
doing this or should I manage the generation of the ids somewhere else?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 5, 2012, 4:58am UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/2 "2012-06-05T04:58:28Z")

</div>

When you send a document without ID, ES will give you one.  
It's not a counter but a hashcode.

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 5 juin 2012 à 01:48, Daniel Duarte Figueiredo [danielduartefigueiredo@gmail.com](mailto:danielduartefigueiredo@gmail.com) a écrit :

> Is there a way of using identity/autonumber ids in ES similar to a traditional relational database?  
> I have an index called post\_index with "post" documents and I want to assign unique numeric ids to them (1, 2, 3..). Is there an easy way of doing this or should I manage the generation of the ids somewhere else?

---

<div class="post-metadata">

**Author:** ![Andy\_Wick](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andy_wick/32/44017_2.png) [@Andy\_Wick](https://discuss.elastic.co/u/Andy_Wick)\
**Post date:** [June 5, 2012, 12:53pm UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/3 "2012-06-05T12:53:36Z")

</div>

If you really need an auto increment style number instead of the auto  
generated ids, you can use the \_version technique describe  
here [http://blogs.perl.org/users/clinton\_gormley/2011/10/elasticsearchsequence---a-blazing-fast-ticket-server.html](http://blogs.perl.org/users/clinton_gormley/2011/10/elasticsearchsequence---a-blazing-fast-ticket-server.html)

---

<div class="post-metadata">

**Author:** ![Daniel\_Duarte\_Figuei](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@Daniel\_Duarte\_Figuei](https://discuss.elastic.co/u/Daniel_Duarte_Figuei)\
**Post date:** [June 5, 2012, 5:37pm UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/4 "2012-06-05T17:37:13Z")

</div>

Thanks you both. I had noticed the generated hashcode, but I really need an  
auto increment style number, so I will give it a try. Very helpful link.

2012/6/5 Andy Wick [andywick@gmail.com](mailto:andywick@gmail.com)

> If you really need an auto increment style number instead of the auto  
> generated ids, you can use the \_version technique describe here  
> [ElasticSearch::Sequence - a blazing fast ticket server | Clinton Gormley [blogs.perl.org]](http://blogs.perl.org/users/clinton_gormley/2011/10/elasticsearchsequence---a-blazing-fast-ticket-server.html)

---

<div class="post-metadata">

**Author:** ![Nicolai\_Kamenzky](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@Nicolai\_Kamenzky](https://discuss.elastic.co/u/Nicolai_Kamenzky)\
**Post date:** [March 30, 2014, 10:36am UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/5 "2014-03-30T10:36:59Z")

</div>

Hi Daniel, do you use the \_version technique now? Is it working well for  
you?

BTW: I created a node.js module [https://github.com/analog-nico/es-sequence](https://github.com/analog-nico/es-sequence) for  
it.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7f3186a1-0ac9-4980-8e15-75fd329ee312%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7f3186a1-0ac9-4980-8e15-75fd329ee312%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11177](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/11177/32/991_2.png) [@11177](https://discuss.elastic.co/u/11177)\
**Post date:** [January 16, 2015, 7:09pm UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/6 "2015-01-16T19:09:22Z")

</div>

hi, i tried ur module, it is useful & nice. But why sequence version  
increments by 100? is it blank updating 100 times?

On Sunday, March 30, 2014 at 6:36:59 PM UTC+8, Nicolai Kamenzky wrote:

> Hi Daniel, do you use the \_version technique now? Is it working well for  
> you?
> 
> BTW: I created a node.js module  
> [https://github.com/analog-nico/es-sequence](https://github.com/analog-nico/es-sequence) for it.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/beb97bb6-874b-4e08-abb3-04b4e6438119%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/beb97bb6-874b-4e08-abb3-04b4e6438119%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Nicolai\_Kamenzky](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@Nicolai\_Kamenzky](https://discuss.elastic.co/u/Nicolai_Kamenzky)\
**Post date:** [January 16, 2015, 8:44pm UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/7 "2015-01-16T20:44:58Z")

</div>

For better performance the lib fetches 100 ids at a time and caches those.  
This way elasticsearch is only queried every 100th get call.

Do you call init before every get call? This way the cache would be cleared  
each time. init only needs to be called once on startup.

Am Freitag, 16. Januar 2015 14:09:22 UTC-5 schrieb Энхтөр Энхбат:

> hi, i tried ur module, it is useful & nice. But why sequence version  
> increments by 100? is it blank updating 100 times?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c86dc437-3234-40e2-b5d3-68f46bc3545c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c86dc437-3234-40e2-b5d3-68f46bc3545c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:38am UTC](https://discuss.elastic.co/t/identity-autonumber-ids/7973/8 "2017-07-06T00:38:18Z")

</div>


