Convert from Json to aggregration form using ejs(Elasticsearch.js)

I have created a query as per my requirement for fetching the data from Elastic Search Index it is working fine for me, I need to convert it in form of agg using ejs client of elasticsearch.js.
Can anyone please help me it would be appreciated..:slight_smile:
Below is my query:-

{
"aggs": {
"parentsku": {
"terms": {
"field": "parentSku",
"order": {
"_term": "asc"
},
"size": 2
},
"aggs": {
"cost": {
"stats": {
"field": "directCost"
}
},
"sales": {
"stats": {
"field": "revenu"
}
},
"quantity": {
"stats": {
"field": "quantity"
}
}
}
}
},
"query": {
"filtered": {
"filter": {
"range": {
"quantity": {
"gte": "500"
}
}
}
}
}
}