# Elastic search aggregations

**URL:** <https://discuss.elastic.co/t/elastic-search-aggregations/41169>\
**Category:** Elasticsearch\
**Created:** [February 8, 2016, 9:15am UTC](https://discuss.elastic.co/t/elastic-search-aggregations/41169 "2016-02-08T09:15:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ven2286](https://avatars.discourse-cdn.com/v4/letter/v/6f9a4e/32.png) [@ven2286](https://discuss.elastic.co/u/ven2286)\
**Post date:** [February 8, 2016, 9:15am UTC](https://discuss.elastic.co/t/elastic-search-aggregations/41169/1 "2016-02-08T09:15:28Z")

</div>

I have an requirement like this.  
I want to caluclate the distance between objects based on some parameters. Distance formula will be supplied as script.  
So i thought to use scripted metric aggregation. Inside the script i want to use another aggregation like min and max values on some fields. I want to do all this in single query.  
Is this possible?

---

<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 5, 2017, 11:18pm UTC](https://discuss.elastic.co/t/elastic-search-aggregations/41169/2 "2017-07-05T23:18:16Z")

</div>


