After migrating nearly 2billion documents I noticed I DERPED and forgot to set a field we call "mongo_id" on 90% of them.
Is there a way to update all of the documents so that
document.mongo_id = document.meta.id
After migrating nearly 2billion documents I noticed I DERPED and forgot to set a field we call "mongo_id" on 90% of them.
Is there a way to update all of the documents so that
document.mongo_id = document.meta.id
Any update will require reindexing.
That is fine I suppose, do you happen to have an example query on how a field can be set to the value of a documents id?
POST indexname/doctype/_update_by_query
{
"script": {
"source": "ctx._source.id = ctx._id",
"lang": "painless"
},
"query":{
"bool":{
"must_not":{
"exists":{
"field":"mongo_id"
}
}
}
}
}
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.