# Generate ID

**URL:** <https://discuss.elastic.co/t/generate-id/28536>\
**Category:** Elasticsearch\
**Created:** [September 2, 2015, 3:30pm UTC](https://discuss.elastic.co/t/generate-id/28536 "2015-09-02T15:30:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raunak/32/4446_2.png) [@raunak](https://discuss.elastic.co/u/raunak)\
**Post date:** [September 2, 2015, 3:30pm UTC](https://discuss.elastic.co/t/generate-id/28536/1 "2015-09-02T15:30:48Z")

</div>

I understand that ids are automatically generated if one is not provided. After reading this [blog post](https://www.elastic.co/blog/performance-considerations-elasticsearch-indexing), it seems using Java's UUID is not the best choice. Is there a way to use Elastic's internal id generator in my Java code?

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [September 2, 2015, 3:42pm UTC](https://discuss.elastic.co/t/generate-id/28536/2 "2015-09-02T15:42:06Z")

</div>

Unfortunately the code is not separated into a separate dependency, if you want to use it you will need to depend on Elasticsearch itself and use `org.elasticsearch.common.Strings.base64UUID()` to generate a time-based UUID.

---

<div class="post-metadata">

**Author:** ![raunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raunak/32/4446_2.png) [@raunak](https://discuss.elastic.co/u/raunak)\
**Post date:** [September 2, 2015, 4:32pm UTC](https://discuss.elastic.co/t/generate-id/28536/3 "2015-09-02T16:32:25Z")

</div>

Thanks @dakrone. That worked like a charm.  
I'm already using the [ElasticSearch Java library](http://search.maven.org/#artifactdetails%7Corg.elasticsearch%7Celasticsearch%7C1.7.1%7Cjar), so there is no additional dependency for me to add.

---

<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, 11:52pm UTC](https://discuss.elastic.co/t/generate-id/28536/4 "2017-07-05T23:52:34Z")

</div>


