If you use reindex for migration you can check this solution: Reindexing failed - Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 672; - #4 by JinnaBalu
POST /_reindex?wait_for_completion=true&pretty=true
{
"source": {
"index": "student"
},
"dest": {
"index": "new_student"
},
"script": {
"source": "if (ctx._id.length() > 512) {ctx._id = null}",
"lang": "painless"
}
}