# How can I use percentile aggregation result as a range query boundary

**URL:** <https://discuss.elastic.co/t/how-can-i-use-percentile-aggregation-result-as-a-range-query-boundary/181136>\
**Category:** Elasticsearch\
**Created:** [May 15, 2019, 9:20am UTC](https://discuss.elastic.co/t/how-can-i-use-percentile-aggregation-result-as-a-range-query-boundary/181136 "2019-05-15T09:20:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cherie](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@Cherie](https://discuss.elastic.co/u/Cherie)\
**Post date:** [May 15, 2019, 9:20am UTC](https://discuss.elastic.co/t/how-can-i-use-percentile-aggregation-result-as-a-range-query-boundary/181136/1 "2019-05-15T09:20:31Z")

</div>

Hi,  
I want to write a filter which can pick out 95 percent hits. These hits `TotalTiming` field range from 0 to P95 of All TotalTiming. So I wonder how can I use this 95 percentile aggregation result as a range query top line. It is a variable, but the range query seems to only accept numeric param.  
If this cannot be realized, are there other solutions can achieve this feature?

---

<div class="post-metadata">

**Author:** ![Cherie](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@Cherie](https://discuss.elastic.co/u/Cherie)\
**Post date:** [May 16, 2019, 6:51am UTC](https://discuss.elastic.co/t/how-can-i-use-percentile-aggregation-result-as-a-range-query-boundary/181136/2 "2019-05-16T06:51:19Z")

</div>

Anyone here？

---

<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:** [June 13, 2019, 6:51am UTC](https://discuss.elastic.co/t/how-can-i-use-percentile-aggregation-result-as-a-range-query-boundary/181136/3 "2019-06-13T06:51:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
