# Runtime\_mapping for aggregation context?

**URL:** <https://discuss.elastic.co/t/runtime-mapping-for-aggregation-context/298886>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [March 5, 2022, 5:29am UTC](https://discuss.elastic.co/t/runtime-mapping-for-aggregation-context/298886 "2022-03-05T05:29:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [March 5, 2022, 5:29am UTC](https://discuss.elastic.co/t/runtime-mapping-for-aggregation-context/298886/1 "2022-03-05T05:29:12Z")

</div>

Hello !

I have a requirement which I would need calculate the total amount spiked compared to previous of latest month.

I was able to achieve this by using [watcher](https://gist.github.com/yuwtennis/7a872b1fbeb99d27168acc98f0fa4924#file-watcher) .

However, this would be dependent on _watcher_ so I am looking for possibility in _\_search_ context , perhaps using _runtime\_mapping_, but in [the doc](https://www.elastic.co/guide/en/elasticsearch/painless/7.17/painless-runtime-fields-context.html), I was not able to find a way to **access the aggregation result**.  
`e.g aggs[AGGREGATION_NAME] instead of doc[FIELD_NAME] `

Would there be any way to process the aggregation result in search context ?

Thanks,  
Yu

---

<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:** [April 2, 2022, 5:30am UTC](https://discuss.elastic.co/t/runtime-mapping-for-aggregation-context/298886/2 "2022-04-02T05:30:07Z")

</div>

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