I guess that was a tough one... This is the working script I've came up with:
GET /unittesttg1_tg1_fq1/_search
{
"size": 0,
"aggs": {
"groupby": {
"terms": {
"script": {
"inline": "ZonedDateTime ztz = ZonedDateTime.ofInstant(Instant.ofEpochMilli(doc['LAST_MODIFIED_DATE'].value), ZoneId.of('UTC')); ztz.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);"
},
"size": 60
}
}
}
}