i have the following mapping in my ES:
{
"properties": {
"id": {
"type": "keyword",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"creationTime": {
"type": "date"
},
"duration": {
"type": "long"
}
}
}
and i want to calculate percentile, based on latest X(1000 for example) documents, per ID
what i have for now is that:
{
"size": 0,
"aggs": {
"ids": {
"terms": {
"field": "id",
"size": 20000
},
"aggs": {
"percentileByDuration": {
"percentiles": {
"field": "duration",
"percents": [
50
]
}
}
}
}
}
}
but any form of making get only the latest 1000 documents, i get an error such as sub aggregation not supported and etc.
how can i manage to achieve my goal?
p.s. the 20k on the terms size is because i only want any 20k id's