# Aggregation on result set

**URL:** https://discuss.elastic.co/t/aggregation-on-result-set/72953
**Category:** Elasticsearch
**Created:** [January 26, 2017, 9:29pm UTC](https://discuss.elastic.co/t/aggregation-on-result-set/72953 "2017-01-26T21:29:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![satishsnv](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@satishsnv](https://discuss.elastic.co/u/satishsnv)
#### Post date: [January 26, 2017, 9:29pm UTC](https://discuss.elastic.co/t/aggregation-on-result-set/72953/1 "2017-01-26T21:29:05Z")

</div>

Hi,

i have 2 queries  
Can i do an aggregation on a queried data?  
on an aggregation result can i perform any query?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [January 26, 2017, 9:29pm UTC](https://discuss.elastic.co/t/aggregation-on-result-set/72953/2 "2017-01-26T21:29:38Z")

</div>

No you cannot.

---

<div class="post-metadata">

### Author: ![satishsnv](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@satishsnv](https://discuss.elastic.co/u/satishsnv)
#### Post date: [January 27, 2017, 11:14am UTC](https://discuss.elastic.co/t/aggregation-on-result-set/72953/3 "2017-01-27T11:14:55Z")

</div>

i ran the following aggregation

"aggs": {  
"userdetails": {  
"terms": {  
"field": "userName"  
},  
"aggs": {  
"infodetails": {  
"cardinality": {  
"field": "info"  
}  
}  
}  
}  
}

with the above aggregation got the following results  
"aggregations": {  
"userdetails": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 0,  
"buckets": [  
{  
"key": "test1",  
"doc\_count": 2,  
"infodetails": {  
"value": 2  
}  
},  
{  
"key": "test2",  
"doc\_count": 1,  
"infodetails": {  
"value":1  
}  
}  
]  
}  
}

if i want to restrict buckets based on cardinality value. what is the way?  
for example in the above scenario i got 2 results one with value 1 and other with 2.  
suppose i want to have buckets with cardinality more than 2?  
this is the requirement i have, please let me know what can i use to achieve this

---

<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 24, 2017, 11:15am UTC](https://discuss.elastic.co/t/aggregation-on-result-set/72953/4 "2017-02-24T11:15:06Z")

</div>

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