Percentile based on aggregated data

My problem:
There are a lot of documents with the following structure (example):

{"someId" : 1, "someCounter": 2}
{"someId" : 1, "someCounter": 1}
{"someId" : 2, "someCounter": 3}
{"someId" : 3, "someCounter": 5}
{"someId" : 3, "someCounter": 1}
{"someId" : 3, "someCounter": 3}

I want to calculate the percentile of the amount of the *someCounter *grouped
by someId:

Request example

"aggs": {
"someId": {
"terms": {
"field": "someId"
},
"aggs": {
"someCounter_sum": {
"sum": {
"field": "someCounter"
},
"aggs": {
"percentile": {
"percentiles": {
// ?
}
}
}
}
}
}
}

Response example

"aggregations": {
"name": {
"percentile": {
"99.0": 0.001
}
}
}

I’m trying to aggregate with terms, sum and percentiles, but I’m not
sure if it is possible. I also tried script field with the same result.
Is it possible to calculate percentile based on aggregated data on
elasticsearch?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a1831d55-d521-42bc-a846-a6211c6f19a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.