@@ -17,14 +17,19 @@ PUT _ingest/pipeline/spotify-stream-pipeline
17
17
{"rename" : { "field" : " track_duration_ms" , "target_field" : " track.duration_ms" , "ignore_missing" : true }},
18
18
{"rename" : { "field" : " track_popularity" , "target_field" : " track.popularity" , "ignore_missing" : true }},
19
19
{"rename" : { "field" : " track_is_in_library" , "target_field" : " track.is_in_library" , "ignore_missing" : true }},
20
- {"rename" : { "field" : " track_is_unplayable" , "target_field" : " track.is_unplayable" , "ignore_missing" : true }},
20
+ {"rename" : { "field" : " track_is_explicit" , "target_field" : " track.is_explicit" , "ignore_missing" : true }},
21
+ {"rename" : { "field" : " track_is_local" , "target_field" : " track.is_local" , "ignore_missing" : true }},
22
+ {"rename" : { "field" : " track_is_playable" , "target_field" : " track.is_playable" , "ignore_missing" : true }},
21
23
{"rename" : { "field" : " album_uri" , "target_field" : " album.uri" , "ignore_missing" : true }},
24
+ {"rename" : { "field" : " album_name" , "target_field" : " album.name" , "ignore_missing" : true }},
25
+ {"rename" : { "field" : " album_type" , "target_field" : " album.type" , "ignore_missing" : true }},
26
+ {"rename" : { "field" : " album_release_date" , "target_field" : " album.release_date" , "ignore_missing" : true }},
22
27
{"rename" : { "field" : " stream_username" , "target_field" : " stream_context.username" , "ignore_missing" : true }},
23
28
{"rename" : { "field" : " stream_platform" , "target_field" : " stream_context.platform" , "ignore_missing" : true }},
29
+ {"rename" : { "field" : " stream_normalized_platform" , "target_field" : " stream_context.normalized_platform" , "ignore_missing" : true }},
24
30
{"rename" : { "field" : " stream_conn_country" , "target_field" : " stream_context.conn_country" , "ignore_missing" : true }},
25
31
{"rename" : { "field" : " stream_ip_addr_decrypted" , "target_field" : " stream_context.ip_addr_decrypted" , "ignore_missing" : true }},
26
32
{"rename" : { "field" : " stream_user_agent_decrypted" , "target_field" : " stream_context.user_agent_decrypted" , "ignore_missing" : true }},
27
- {"rename" : { "field" : " stream_album_name" , "target_field" : " album.name" , "ignore_missing" : true }},
28
33
{"rename" : { "field" : " stream_reason_start" , "target_field" : " stream_context.reason_start" , "ignore_missing" : true }},
29
34
{"rename" : { "field" : " stream_reason_end" , "target_field" : " stream_context.reason_end" , "ignore_missing" : true }},
30
35
{"rename" : { "field" : " stream_shuffle" , "target_field" : " stream_context.shuffle" , "ignore_missing" : true }},
@@ -44,36 +49,18 @@ PUT _ingest/pipeline/spotify-stream-pipeline
44
49
{"rename" : { "field" : " track_audio_feature_valence" , "target_field" : " audio_features.valence" , "ignore_missing" : true }},
45
50
{"rename" : { "field" : " track_audio_feature_tempo" , "target_field" : " audio_features.tempo" , "ignore_missing" : true }},
46
51
{"rename" : { "field" : " track_audio_feature_time_signature" , "target_field" : " audio_features.time_signature" , "ignore_missing" : true }},
47
- {"remove" : { "field" : [" track_src_id" , " location" ], "ignore_missing" : true }},
48
52
{"user_agent" : { "field" : " stream_context.user_agent_decrypted" , "ignore_missing" : true }},
49
- {
50
- "script" : {
51
- "source" : " " "
52
- String platform = ctx['stream_context']['platform'];
53
- String lcp = platform.toLowerCase();
54
- if (lcp.startsWith('ios') || lcp.startsWith('partner ios_sdk')) {
55
- platform = 'iOS';
56
- } else if (lcp.startsWith('os x') || lcp.startsWith('osx')) {
57
- platform = 'OS X';
58
- } else if (lcp.startsWith('partner sonos_')) {
59
- platform = 'Sonos';
60
- } else if (lcp.startsWith('partner google cast_tv') || lcp.startsWith('partner google cast')) {
61
- platform = 'Chromecast';
62
- } else if (lcp.startsWith('partner android_tv')) {
63
- platform = 'Android TV';
64
- } else if (lcp.startsWith('android os') || lcp.startsWith('android [arm 0 ]')|| lcp.startsWith('android-tablet os')) {
65
- platform = 'Android OS';
66
- } else if (lcp.startsWith('webplayer') || lcp.startsWith('web_player') || lcp.startsWith('partner spotify web_player')) {
67
- platform = 'WebPlayer';
68
- } else if (lcp.startsWith('partner webos_tv') || lcp.startsWith('WebOs TV')) {
69
- platform = 'WebOs TV';
70
- } else if (lcp.startsWith('windows')) {
71
- platform = 'Windows';
72
- }
73
- ctx['stream_context']['normalized_platform'] = platform
74
- " " "
75
- }
76
- }
53
+ {"convert" : { "field" : " stream_context.offline" , "type" : " boolean" , "ignore_missing" : true }},
54
+ {"convert" : { "field" : " stream_context.shuffle" , "type" : " boolean" , "ignore_missing" : true }},
55
+ {"convert" : { "field" : " stream_context.incognito_mode" , "type" : " boolean" , "ignore_missing" : true }},
56
+ {"convert" : { "field" : " stream_context.skipped" , "type" : " boolean" , "ignore_missing" : true }},
57
+ {"convert" : { "field" : " track.is_in_library" , "type" : " boolean" , "ignore_missing" : true }},
58
+ {"convert" : { "field" : " track.is_explicit" , "type" : " boolean" , "ignore_missing" : true }},
59
+ {"convert" : { "field" : " track.is_local" , "type" : " boolean" , "ignore_missing" : true }},
60
+ {"convert" : { "field" : " track.is_playable" , "type" : " boolean" , "ignore_missing" : true }},
61
+ {"convert" : { "field" : " is_new_track" , "type" : " boolean" , "ignore_missing" : true }},
62
+ {"convert" : { "field" : " is_new_artist" , "type" : " boolean" , "ignore_missing" : true }},
63
+ {"convert" : { "field" : " is_new_album" , "type" : " boolean" , "ignore_missing" : true }}
77
64
]
78
65
}
79
66
```
@@ -101,7 +88,8 @@ PUT _component_template/spotify-stream-mapping
101
88
"danceability" : {"type" : " integer" },
102
89
"key" : {"type" : " integer" },
103
90
"speechiness" : {"type" : " integer" },
104
- "energy" : {"type" : " integer" }
91
+ "energy" : {"type" : " integer" },
92
+ "time_signature" : {"type" : " integer" }
105
93
}
106
94
},
107
95
"stream_context" : {
@@ -132,7 +120,9 @@ PUT _component_template/spotify-stream-mapping
132
120
"album" : {
133
121
"properties" : {
134
122
"name" : {"type" : " keyword" },
135
- "uri" : {"type" : " keyword" }
123
+ "uri" : {"type" : " keyword" },
124
+ "type" : {"type" : " keyword" },
125
+ "release_date" : {"format" : " year||year_month||year_month_day" , "type" : " date" }
136
126
}
137
127
},
138
128
"track" : {
@@ -142,15 +132,20 @@ PUT _component_template/spotify-stream-mapping
142
132
"name" : {"type" : " keyword" },
143
133
"uri" : {"type" : " keyword" },
144
134
"is_in_library" : {"type" : " boolean" },
145
- "is_unplayable" : {"type" : " boolean" }
135
+ "is_explicit" : {"type" : " boolean" },
136
+ "is_local" : {"type" : " boolean" },
137
+ "is_playable" : {"type" : " boolean" }
146
138
}
147
139
},
148
140
"end_time" : {"format" : " yyyy-MM-dd'T'HH:mm:ss'Z'" , "type" : " date" },
149
141
"percentage_played" : {"type" : " long" },
150
142
"day_name" : {"type" : " keyword" },
151
143
"month_name" : {"type" : " keyword" },
152
144
"ms_played" : {"type" : " long" },
153
- "min_played" : {"type" : " long" }
145
+ "min_played" : {"type" : " long" },
146
+ "is_new_track" : {"type" : " boolean" },
147
+ "is_new_artist" : {"type" : " boolean" },
148
+ "is_new_album" : {"type" : " boolean" }
154
149
}
155
150
}
156
151
}
0 commit comments