# Maximum length of a specified document ID

**URL:** <https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262>\
**Category:** Elasticsearch\
**Created:** [April 20, 2011, 4:37am UTC](https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262 "2011-04-20T04:37:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwho](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cwho](https://discuss.elastic.co/u/cwho)\
**Post date:** [April 20, 2011, 4:37am UTC](https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262/1 "2011-04-20T04:37:14Z")

</div>

Is there a limit on the maximum length of a document ID in elastic  
search?

When I index docs, I pass in my desired IDs, and for some uses we are  
using strings that can get quite long - like 600 characters, perhaps.  
I like to know if there is a hard limit, or a performance limit, to  
this.....

e.g.  
curl -XPUT '[http://localhost:9200/twitter/tweet/AIFEFE723489SDKJSD](http://localhost:9200/twitter/tweet/AIFEFE723489SDKJSD)...  
(600 characters or more)'

Thanks!

---

<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:** [April 20, 2011, 9:50am UTC](https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262/2 "2011-04-20T09:50:08Z")

</div>

There isn't a limit, but it can become wasteful space / memory wise.  
On Wednesday, April 20, 2011 at 7:37 AM, cwho80 wrote:

> Is there a limit on the maximum length of a document ID in elastic  
> search?
> 
> When I index docs, I pass in my desired IDs, and for some uses we are  
> using strings that can get quite long - like 600 characters, perhaps.  
> I like to know if there is a hard limit, or a performance limit, to  
> this.....
> 
> e.g.  
> curl -XPUT '[http://localhost:9200/twitter/tweet/AIFEFE723489SDKJSD](http://localhost:9200/twitter/tweet/AIFEFE723489SDKJSD)...  
> (600 characters or more)'
> 
> Thanks!

---

<div class="post-metadata">

**Author:** ![iamthealex](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@iamthealex](https://discuss.elastic.co/u/iamthealex)\
**Post date:** [December 13, 2016, 6:56pm UTC](https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262/3 "2016-12-13T18:56:38Z")

</div>

I think there is a maximum now.  
When I upgraded to ES V5.0, I got messages of the form:

id is too long, must be no longer than 512 bytes but was 1010

and a google search found this file:

[https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java](https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java)

with this requirement:

```
    if (id != null && id.getBytes(StandardCharsets.UTF_8).length > 512) {
        validationException = addValidationError("id is too long, must be no longer than 512 bytes but was: " +
                        id.getBytes(StandardCharsets.UTF_8).length, validationException);
    }
```

---

<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, 10:05pm UTC](https://discuss.elastic.co/t/maximum-length-of-a-specified-document-id/4262/4 "2017-07-05T22:05:00Z")

</div>


