# Percentiles from buckets

**URL:** <https://discuss.elastic.co/t/percentiles-from-buckets/22343>\
**Category:** Elasticsearch\
**Created:** [February 24, 2015, 1:20am UTC](https://discuss.elastic.co/t/percentiles-from-buckets/22343 "2015-02-24T01:20:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bas1](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Bas1](https://discuss.elastic.co/u/Bas1)\
**Post date:** [February 24, 2015, 1:20am UTC](https://discuss.elastic.co/t/percentiles-from-buckets/22343/1 "2015-02-24T01:20:18Z")

</div>

Hello everyone,

Our database contains prebucketed data, for example:

"metric": [  
{  
"bucket": 2832,  
"count": 25  
}  
]

We want to retrieve percentiles based on the bucket/count combination.  
Consider this simplified example:

bucket count  
1 3  
5 4

Should be viewed as the following set when calculating percentiles:

111 5555

Is there a way to do this using script metric aggregations or should we  
write a plugin for this?

Thank you, regards,

Bas

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/60f91b12-4f69-48fd-9fff-c5d5762bad8c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/60f91b12-4f69-48fd-9fff-c5d5762bad8c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 26, 2015, 11:39pm UTC](https://discuss.elastic.co/t/percentiles-from-buckets/22343/2 "2015-02-26T23:39:23Z")

</div>

You should be able to do it using a script by returning an array that  
contains `count` occurrences of `bucket`.

On Tue, Feb 24, 2015 at 2:20 AM, Bas [blbrekelmans@gmail.com](mailto:blbrekelmans@gmail.com) wrote:

> Hello everyone,
> 
> Our database contains prebucketed data, for example:
> 
> "metric": [  
> {  
> "bucket": 2832,  
> "count": 25  
> }  
> ]
> 
> We want to retrieve percentiles based on the bucket/count combination.  
> Consider this simplified example:
> 
> bucket count  
> 1 3  
> 5 4
> 
> Should be viewed as the following set when calculating percentiles:
> 
> 111 5555
> 
> Is there a way to do this using script metric aggregations or should we  
> write a plugin for this?
> 
> Thank you, regards,
> 
> Bas
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/60f91b12-4f69-48fd-9fff-c5d5762bad8c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/60f91b12-4f69-48fd-9fff-c5d5762bad8c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/60f91b12-4f69-48fd-9fff-c5d5762bad8c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/60f91b12-4f69-48fd-9fff-c5d5762bad8c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7mcpXpuPMRcFGjZcEpDCP0L-V28YGmmi-ffL\_3ORMU5g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7mcpXpuPMRcFGjZcEpDCP0L-V28YGmmi-ffL_3ORMU5g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:29am UTC](https://discuss.elastic.co/t/percentiles-from-buckets/22343/3 "2017-07-06T00:29:41Z")

</div>


