I want to return the most recent document of all results of the aggregations, but it is returning all the documents How can I solve that?
{
"aggs": {
"nested": {
"nested": {
"path": "data.add"
},
"aggs": {
"desc": {
"terms": {
"field": "data.add.desc.keyword"
},
"aggs": {
"nested": {
"nested": {
"path": "data.add.services"
},
"aggs": {
"mobilephone": {
"filter": {
"term": {
"data.add.services.mobilephone": "true"
}
},
"aggs": {
"street": {
"cardinality": {
"field": "data.add.services.street.keyword"
}
},
"range":{
"top_hits": {
"size": 1,
"sort": [
{"created_at.keyword": {"order": "desc"}}]
}
}
}
}
}
}
}
}
}
}
}
}