# Aggregations count

**URL:** <https://discuss.elastic.co/t/aggregations-count/38026>\
**Category:** Elasticsearch\
**Created:** [December 28, 2015, 8:03am UTC](https://discuss.elastic.co/t/aggregations-count/38026 "2015-12-28T08:03:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesRadar](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@JamesRadar](https://discuss.elastic.co/u/JamesRadar)\
**Post date:** [December 28, 2015, 8:03am UTC](https://discuss.elastic.co/t/aggregations-count/38026/1 "2015-12-28T08:03:27Z")

</div>

Hi, I'm dealing with problem about aggregation problem with counts of unique documents.

I have two types e\_params and e\_products. E\_products is an parent to e\_params.

And i have this query for filtering based on user filters. With this query i count of documents in each params (like color, size, weight).

And this query working good. But not for parameter which user choose. So if user choose color: black. Counts of other params return good. But not the color. That's understandable. But I need to remove the query term of child which sets color: black. And do the aggregations of color on that. Is it possible to do in one query? Or I need to do it with multiple queries? In this count for parameter color i need other queries on parent.

array (2)  
query =\> array (1)  
bool =\> array (1)  
must =\> array (3)  
0 =\> array (1)  
range =\> array (1)  
priceVat =\> array (2)  
from =\> 0.0  
to =\> 27500.0  
1 =\> array (1)  
term =\> array (1)  
"categories.e\_category\_id" =\> array (2)  
value =\> 9  
boost =\> 1.0  
2 =\> array (1)  
has\_child =\> array (2)  
type =\> "e\_params" (8)  
query =\> array (1)  
bool =\> array (1)  
must =\> array (2)  
0 =\> array (1)  
term =\> array (1)  
param\_type\_id =\> array (2)  
value =\> 191  
boost =\> 1.0  
1 =\> array (1)  
terms =\> array (1)  
param\_value =\> array (1)  
0 =\> "2,5" (3)  
aggs =\> array (1)  
ks =\> array (2)  
children =\> array (1)  
type =\> "e\_params" (8)  
aggs =\> array (1)  
ks =\> array (2)  
terms =\> array (1)  
field =\> "param\_type\_id" (13)  
aggs =\> array (1)  
ks =\> array (1)  
terms =\> array (1)  
field =\> "param\_value" (11)

`

 ![](https://us1.discourse-cdn.com/elastic/original/2X/6/6620bd6315c4cea3f38dfeea8e43241b4b6e5e1a.png)

---

<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, 11:28pm UTC](https://discuss.elastic.co/t/aggregations-count/38026/2 "2017-07-05T23:28:20Z")

</div>


