# How to put a filter in an aggs?

**URL:** <https://discuss.elastic.co/t/how-to-put-a-filter-in-an-aggs/18578>\
**Category:** Elasticsearch\
**Created:** [July 10, 2014, 1:56pm UTC](https://discuss.elastic.co/t/how-to-put-a-filter-in-an-aggs/18578 "2014-07-10T13:56:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mqseries\_MQSupervise](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Mqseries\_MQSupervise](https://discuss.elastic.co/u/Mqseries_MQSupervise)\
**Post date:** [July 10, 2014, 1:56pm UTC](https://discuss.elastic.co/t/how-to-put-a-filter-in-an-aggs/18578/1 "2014-07-10T13:56:43Z")

</div>

my request :

"aggs": {  
"lastMsg": {  
"terms": { "field": "host", "size" : 0 },  
"aggs" : {  
"max\_date" : { "max" : { "field" : "\_msr\_datetime" } }  
}  
}  
}

response :

aggregations: {  
lastMsg: { buckets: [

- {
  - key: opacpas6
  - doc\_count: 10
  - max\_date: {
    - value: 1405007491779  
}  
}

- {
  - key: opacpas8
  - doc\_count: 20
  - max\_date: {
    - value: 1405007490895  
}  
}

- {
  - key: opacpas7
  - doc\_count: 30
  - max\_date: {
    - value: 1405007491728  
}  
}

i would like to aggregate "max\_date" for doc\_count \> 10  
possible ?

thx  
patrick

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9aacb3c8-0066-4e41-a7c9-1d953cbe38fd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9aacb3c8-0066-4e41-a7c9-1d953cbe38fd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:16am UTC](https://discuss.elastic.co/t/how-to-put-a-filter-in-an-aggs/18578/2 "2017-07-06T01:16:48Z")

</div>


