The first thing to do would be
split { field => "playlists" }
split { field => "[playlists][tracks]" }
at that point you will have one event for each track and I think each one will look like this (AWS US East is down this afternoon, or I would test it)
"playlists": {
"name": "Rock",
"collaborative": "false",
"pid": 0,
"modified_at": 1493424000,
"num_tracks": 22,
"num_albums": 27,
"num_followers": 1,
"tracks": {
"pos": 0,
"artist_name": "Michael Jackson",
"track_uri": "spotify:track:0UaMYEvWZi0ZqiDOoHU3YI",
"artist_uri": "spotify:d5F5d7go1WT98tk",
"track_name": "Song",
"album_uri": "spotify:album:6vV5Udzzf4Qo2I9K",
"duration_ms": 226863,
"album_name": "The Cookbook"
},
"num_edits": 34,
"duration_ms": 9065801,
"num_artists": 37
},
So then you can
mutate {
rename => {
"[playlists][tracks]" => "track"
"[playlists][name]" => "[playlist][name]"
"[playlists][pid]" => "[playlist][pid]"
}
remove_field => "playlists"
}
If you want the fields inside [track] to be at the top level use a ruby filter like this.