# Reindexing failed - Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 672;

**URL:** <https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650>\
**Category:** Elasticsearch\
**Created:** [June 13, 2019, 1:19pm UTC](https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650 "2019-06-13T13:19:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JinnaBalu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jinnabalu/32/27899_2.png) [@JinnaBalu](https://discuss.elastic.co/u/JinnaBalu)\
**Post date:** [June 13, 2019, 1:19pm UTC](https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650/1 "2019-06-13T13:19:51Z")

</div>

I am reindexing the elasticsearch with the cluster restart from 2.4.1 to 5.6.16, I have reindexed few indices successfull. Out of 23 indices 3 are getting failed duw to the Validation Failure with the id.

> Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 672;

> Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 549;2: id is too long, must be no longer than 512 bytes but was: 517;3: id is too long, must be no longer than 512bytes but was: 532;4: id is too long, must be no longer than 512 bytes but was: 719;5: id is too long, must be no longer than 512 bytes but was: 1374;6: id is too long, must be no longer than 512 bytes but was:614;7: id is too long, must be no longer than 512 bytes but was: 623;8: id is too long, must be no longer than 512 bytes but was: 543;9: id is too long, must be no longer than 512 bytes but was: 895;10: id is too long, must be no longer than 512 bytes but was: 697;11: id is too long, must be no longer than 512 bytes but was: 1064;12: id is too long, must be no longer than 512 bytes but was: 785;13: id is too long, must be no longer than 512 bytes but was: 600;14: id is too long, must be no longer than 512 bytes but was: 537;15: id is too long, must be no longer than 512 bytes but was: 870;16: id is too long, must be no longer than 512 bytes but was: 802;17: id is too long, must be no longer than 512 bytes but was: 716;18: id is too long, must be no longer than 512 bytes but was: 844;19: id is too long, must be no longer than 512 bytes but was: 1503;20: id is too long, must be no longer than 512 bytes but was: 734;21: id is too long, must be no longer than 512 bytes but was: 590;22: id is too long, must be no longer than 512 bytes but was:697;23: id is too long, must be no longer than 512 bytes but was: 1008;24: id is too long, must be no longer than 512 bytes but was: 1146;25: id is too long, must be no longer than 512 bytes but was: 609;26: idis too long, must be no longer than 512 bytes but was: 988;27: id is too long, must be no longer than 512 bytes but was: 703;28: id is too long, must be no longer than 512 bytes but was: 568;29: id is too long,must be no longer than 512 bytes but was: 726;30: id is too long, must be no longer than 512 bytes but was: 737;31: id is too long, must be no longer than 512 bytes but was: 611;32: id is too long, must be no longer than 512 bytes but was: 914;

---

<div class="post-metadata">

**Author:** ![whatgeorgemade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whatgeorgemade/32/103246_2.png) [@whatgeorgemade](https://discuss.elastic.co/u/whatgeorgemade)\
**Post date:** [June 13, 2019, 4:31pm UTC](https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650/2 "2019-06-13T16:31:04Z")

</div>

This limit is hard-coded and can't be changed, so you'll need to find a way to reduce the length of the ID field.  
A similar issue came up recently and it was noted that the limit isn't documented anywhere. I think the docs are in the process of being updated.

---

<div class="post-metadata">

**Author:** ![JinnaBalu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jinnabalu/32/27899_2.png) [@JinnaBalu](https://discuss.elastic.co/u/JinnaBalu)\
**Post date:** [June 14, 2019, 2:45am UTC](https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650/3 "2019-06-14T02:45:57Z")

</div>

Doing it manually is very infinite steps to identify the records, i have same data in other database along with elasticsearch.

Elasticsearch team may need to suggest something.

---

<div class="post-metadata">

**Author:** ![JinnaBalu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jinnabalu/32/27899_2.png) [@JinnaBalu](https://discuss.elastic.co/u/JinnaBalu)\
**Post date:** [June 18, 2019, 4:37am UTC](https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650/4 "2019-06-18T04:37:05Z")

</div>

I solved this issue with replacing the \_id value with new hash.

**Issue Logs :** Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 20456;2: id is too long, must be no longer than 512 bytes but was: 537;3: id is too long, must be no longer than 512 bytes but was: 10978;4: id is too long, must be no longer than 512 bytes but was: 544;

**Solution :**

- Run the following reindexing script for the indexes whose \_id is more than 512 bytes

1. Index _new\_student_

> curl -X DELETE "localhost:9200/new\_student?pretty=true"

> curl -X POST "localhost:9200/\_reindex?wait\_for\_completion=true&pretty=true" -H 'Content-Type: application/json' -d'  
> {  
> "source": {  
> "index": "student"  
> },  
> "dest": {  
> "index": "new\_student"  
> },  
> "script": {  
> "source": "if (ctx.\_id.length() \> 512) {ctx.\_id = 'null'}",  
> "lang": "painless"  
> }  
> }' \>\> student.txt

---

<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 16, 2019, 4:37am UTC](https://discuss.elastic.co/t/reindexing-failed-validation-failed-1-id-is-too-long-must-be-no-longer-than-512-bytes-but-was-672/185650/5 "2019-07-16T04:37:12Z")

</div>

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