Last active
November 16, 2022 11:34
-
-
Save padusumilli/1e5261672fff2df7d4218e32d2d7717e to your computer and use it in GitHub Desktop.
Elastic reindex with array field changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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