# Re: Why isn't Elasticsearch using Sha1 for id?

**URL:** <https://discuss.elastic.co/t/re-why-isnt-elasticsearch-using-sha1-for-id/4968>\
**Category:** Elasticsearch\
**Created:** [July 26, 2011, 10:44pm UTC](https://discuss.elastic.co/t/re-why-isnt-elasticsearch-using-sha1-for-id/4968 "2011-07-26T22:44:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Pilone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_pilone/32/3261_2.png) [@Dan\_Pilone](https://discuss.elastic.co/u/Dan_Pilone)\
**Post date:** [July 26, 2011, 10:44pm UTC](https://discuss.elastic.co/t/re-why-isnt-elasticsearch-using-sha1-for-id/4968/1 "2011-07-26T22:44:24Z")

</div>

Do you mean SHA1 of the document itself? I'm pretty sure that would be a  
problem for us as we can have nested documents with identical values. For  
example, you could have:

\<some\_doc\>  
  
Dan  
Pilone  
  
...  
\</some\_doc\>

If "author" is indexed as a nested document it will need an id which can't  
just be the SHA1 of the content we provided. Now I suppose if it has the  
\_parentId as part of the "content" then the SHA1 would be different, but I  
don't know when/how the parent id is associated with nested docs. -- Dan

--  
Dan Pilone  
Managing Partner, Element 84 LLC  
[www.element84.com](http://www.element84.com) / [dan@element84.com](mailto:dan@element84.com) / 703-622-7370

On Tue, Jul 26, 2011 at 6:25 PM, ajsie [johnny.weng.luu@gmail.com](mailto:johnny.weng.luu@gmail.com) wrote:

> CouchDB is using a 40 long characters SHA1 id and they say that the  
> risk is very minimal.
> 
> I wonder if there is a risk that the id Elastic search auto generates  
> will collide with another one since it's only 22 characters long.

---

<div class="post-metadata">

**Author:** ![Paul\_Loy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@Paul\_Loy](https://discuss.elastic.co/u/Paul_Loy)\
**Post date:** [July 26, 2011, 10:55pm UTC](https://discuss.elastic.co/t/re-why-isnt-elasticsearch-using-sha1-for-id/4968/2 "2011-07-26T22:55:15Z")

</div>

You can supply your own ids...

On Tue, Jul 26, 2011 at 11:44 PM, Dan Pilone [dan@element84.com](mailto:dan@element84.com) wrote:

> Do you mean SHA1 of the document itself? I'm pretty sure that would be a  
> problem for us as we can have nested documents with identical values. For  
> example, you could have:
> 
> \<some\_doc\>  
>   
> Dan  
> Pilone  
>   
> ...  
> \</some\_doc\>
> 
> If "author" is indexed as a nested document it will need an id which can't  
> just be the SHA1 of the content we provided. Now I suppose if it has the  
> \_parentId as part of the "content" then the SHA1 would be different, but I  
> don't know when/how the parent id is associated with nested docs. -- Dan
> 
> --  
> Dan Pilone  
> Managing Partner, Element 84 LLC  
> [www.element84.com](http://www.element84.com) / [dan@element84.com](mailto:dan@element84.com) / 703-622-7370
> 
> On Tue, Jul 26, 2011 at 6:25 PM, ajsie [johnny.weng.luu@gmail.com](mailto:johnny.weng.luu@gmail.com) wrote:
> 
> > CouchDB is using a 40 long characters SHA1 id and they say that the  
> > risk is very minimal.
> > 
> > I wonder if there is a risk that the id Elastic search auto generates  
> > will collide with another one since it's only 22 characters long.

## --

Paul Loy  
[paul@keteracel.com](mailto:paul@keteracel.com)  
[http://uk.linkedin.com/in/paulloy](http://uk.linkedin.com/in/paulloy)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 27, 2011, 4:11am UTC](https://discuss.elastic.co/t/re-why-isnt-elasticsearch-using-sha1-for-id/4968/3 "2011-07-27T04:11:40Z")

</div>

The id generated is a type4 UUID (128bit) that is then base64 to reserve  
space.

On Wed, Jul 27, 2011 at 1:25 AM, ajsie [johnny.weng.luu@gmail.com](mailto:johnny.weng.luu@gmail.com) wrote:

> CouchDB is using a 40 long characters SHA1 id and they say that the  
> risk is very minimal.
> 
> I wonder if there is a risk that the id Elastic search auto generates  
> will collide with another one since it's only 22 characters long.

---

<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, 3:59am UTC](https://discuss.elastic.co/t/re-why-isnt-elasticsearch-using-sha1-for-id/4968/4 "2017-07-06T03:59:11Z")

</div>


