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

**URL:** <https://discuss.elastic.co/t/convert-from-json-to-aggregration-form-using-ejs-elasticsearch-js/49124>\
**Category:** Elasticsearch\
**Created:** [May 4, 2016, 4:40am UTC](https://discuss.elastic.co/t/convert-from-json-to-aggregration-form-using-ejs-elasticsearch-js/49124 "2016-05-04T04:40:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawan\_Sharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawan_sharma/32/9478_2.png) [@Pawan\_Sharma](https://discuss.elastic.co/u/Pawan_Sharma)\
**Post date:** [May 4, 2016, 4:40am UTC](https://discuss.elastic.co/t/convert-from-json-to-aggregration-form-using-ejs-elasticsearch-js/49124/1 "2016-05-04T04:40:58Z")

</div>

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..🙂  
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"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:54pm UTC](https://discuss.elastic.co/t/convert-from-json-to-aggregration-form-using-ejs-elasticsearch-js/49124/2 "2017-07-05T22:54:09Z")

</div>


