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

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