I have a field cid
that I need to get the distinct elements of. But I need the distinct elements based on when they were added to the database. I want to first do a timestamp range filter, then get the term aggregation of cid
. I have tried this approach:
{
"aggs": {
"daterange": {
"range": {
"field": "@timestamp",
"ranges": [
{"from": "2019-05-02", "to": "2019-05-03"}
]
},
"aggs": {
"result": {
"terms": {
"field": "chat_id.keyword"
}
}
}
}
},
"_source":"chat_id"
}
But it doesnt aggregate on cid
.