{\'country\': \'France\', \'collected\': \'2018-03-12\', \'active\': true}
{\'country\': \'France\', \'collected\': \'2018-03-13\', \'active\': true}
{\'country\': \
It sounds like you are looking to filter the aggregation results. I believe you'll need to use a filter bucket for this
Something like:
{
"aggs": {
"group": {
"terms": {
"field": "country"
},
"filter": {
"term": {
"active": true
}
},
"aggs": {
"group_docs": {
"top_hits": {
"size": 1,
"sort": [
{
"collected": {
"order": "desc"
}
}
]
}
}
}
}
}
}