# Create Aggregate filter on kibana

**URL:** <https://discuss.elastic.co/t/create-aggregate-filter-on-kibana/133068>\
**Category:** Elasticsearch\
**Created:** [May 24, 2018, 3:05am UTC](https://discuss.elastic.co/t/create-aggregate-filter-on-kibana/133068 "2018-05-24T03:05:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MGG](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@MGG](https://discuss.elastic.co/u/MGG)\
**Post date:** [May 24, 2018, 3:05am UTC](https://discuss.elastic.co/t/create-aggregate-filter-on-kibana/133068/1 "2018-05-24T03:05:28Z")

</div>

I'm taking data samples every 12 hours across 80 sites. I'm trying to setup a filter for a given site based on the recent collection\_timestamp; I've setup the query as below but how to apply this filter in the kibana filter ?

GET /xyz/\_search?  
{  
"aggs": {  
"group": {  
"terms": {  
"field": "siteName.keyword"  
},  
"aggs": {  
"group\_docs": {  
"top\_hits": {  
"size": 1,  
"sort": [  
{  
"collection\_timestamp": {  
"order": "desc"  
}  
}  
]  
}  
}  
}  
}  
}  
}

---

<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:** [June 21, 2018, 3:05am UTC](https://discuss.elastic.co/t/create-aggregate-filter-on-kibana/133068/2 "2018-06-21T03:05:29Z")

</div>

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