# How to set limit on multiple aggregations in elasticsearch sql plugin

**URL:** <https://discuss.elastic.co/t/how-to-set-limit-on-multiple-aggregations-in-elasticsearch-sql-plugin/70721>\
**Category:** Elasticsearch\
**Created:** [January 5, 2017, 6:44pm UTC](https://discuss.elastic.co/t/how-to-set-limit-on-multiple-aggregations-in-elasticsearch-sql-plugin/70721 "2017-01-05T18:44:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhi\_chinchole](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@abhi\_chinchole](https://discuss.elastic.co/u/abhi_chinchole)\
**Post date:** [January 5, 2017, 6:44pm UTC](https://discuss.elastic.co/t/how-to-set-limit-on-multiple-aggregations-in-elasticsearch-sql-plugin/70721/1 "2017-01-05T18:44:42Z")

</div>

I want to set different limit for different aggregations to query elasticsearch using sql plugin.  
I want to write an equivalent query to following ES query \> {"size":0,"query":{"filtered":{"query":{"query\_string":{"query":"_","analyze\_wildcard":true}},"filter":{"bool":{"must":[{"range":{"start":{"gte":1483640371392,"lte":1483641271392,"format":"epoch\_millis"}}}],"must\_not":[]}}}},"aggs":{"2":{"terms":{"field":"interface-id","size":5,"order":{"\_count":"desc"}},"aggs":{"3":{"terms":{"field":"srcport","size":5,"order":{"\_count":"desc"}}}}}}}  
I tried sql query using [Elasticsearch SQL Plugin](https://github.com/NLPchina/elasticsearch-sql/wiki/Aggregations) SELECT COUNT(_) FROM index GROUP BY interface-id, srcport LIMIT 5 but results comes different than that of ES Query.  
Can someone please help

---

<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:** [February 2, 2017, 6:44pm UTC](https://discuss.elastic.co/t/how-to-set-limit-on-multiple-aggregations-in-elasticsearch-sql-plugin/70721/2 "2017-02-02T18:44:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
