# Possible to store aggregation results in a new index

**URL:** <https://discuss.elastic.co/t/possible-to-store-aggregation-results-in-a-new-index/35546>\
**Category:** Elasticsearch\
**Created:** [November 25, 2015, 12:08pm UTC](https://discuss.elastic.co/t/possible-to-store-aggregation-results-in-a-new-index/35546 "2015-11-25T12:08:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonia](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sonia](https://discuss.elastic.co/u/sonia)\
**Post date:** [November 25, 2015, 12:08pm UTC](https://discuss.elastic.co/t/possible-to-store-aggregation-results-in-a-new-index/35546/1 "2015-11-25T12:08:06Z")

</div>

Hi,  
I want to store results of an elasticsearch aggregation in a new index, In other words I want all of documents that match aggregation are stored in a new index.  
please help me.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [November 25, 2015, 1:51pm UTC](https://discuss.elastic.co/t/possible-to-store-aggregation-results-in-a-new-index/35546/2 "2015-11-25T13:51:32Z")

</div>

There is no built in mechanism for this, but you can certainly write a script to index the result of an aggregation. Have your application execute the aggregation, then extract the portions of the response you are interested and write them back into the cluster under a new index.

I've seen this done sometimes to pre-compute "summaries" of data for easy access later.

---

<div class="post-metadata">

**Author:** ![sonia](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sonia](https://discuss.elastic.co/u/sonia)\
**Post date:** [November 28, 2015, 11:33am UTC](https://discuss.elastic.co/t/possible-to-store-aggregation-results-in-a-new-index/35546/3 "2015-11-28T11:33:02Z")

</div>

Thanks Zachary,  
how to write a script to index the result of an aggregation? Please explain with an example.

---

<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:35pm UTC](https://discuss.elastic.co/t/possible-to-store-aggregation-results-in-a-new-index/35546/4 "2017-07-05T23:35:13Z")

</div>


