Skip to content

Instantly share code, notes, and snippets.

@padusumilli
Last active November 16, 2022 11:34
Show Gist options
  • Save padusumilli/1e5261672fff2df7d4218e32d2d7717e to your computer and use it in GitHub Desktop.
Save padusumilli/1e5261672fff2df7d4218e32d2d7717e to your computer and use it in GitHub Desktop.
Elastic reindex with array field changes
POST _reindex
{
"source": {
"index": "events-2022-09-v2"
},
"dest": {
"index": "events-2022-09-v3"
},
"script": {
"source": """
if(ctx._source.mitreAttckList instanceof List && ctx._source.mitreAttckList.size()>0) {
for (int i=0; i<ctx._source.mitreAttckList.size(); i++) {
ctx._source.mitreAttckList[i].technique = ctx._source.mitreAttckList[i].name;
ctx._source.mitreAttckList[i].tactic = ctx._source.mitreAttckList[i].categories;
ctx._source.mitreAttckList[i].remove("name");
ctx._source.mitreAttckList[i].remove("categories");
}
}
"""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment