{ "aggregations": { "timeslots": { "date_histogram": { "field": "start-time", "interval": "1h" }, "aggregations": { "by_source": { "terms": { "script": "[ doc['hostname'].value, doc['streamer-id.content-id'].value, doc['streamer-id.format'].value, doc['streamer-id.quality'].value ].join('/') ", "size": 0 }, "aggregations": { "avg_clients": { "avg": { "field": "data.client-count" } } } } } } } }