# Can i add Aindex's documents aggregation result into B Index's document?

**URL:** https://discuss.elastic.co/t/can-i-add-aindexs-documents-aggregation-result-into-b-indexs-document/166274
**Category:** Elasticsearch
**Created:** [January 30, 2019, 7:08am UTC](https://discuss.elastic.co/t/can-i-add-aindexs-documents-aggregation-result-into-b-indexs-document/166274 "2019-01-30T07:08:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![teemoGod](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teemogod/32/40817_2.png) [@teemoGod](https://discuss.elastic.co/u/teemoGod)
#### Post date: [January 30, 2019, 7:08am UTC](https://discuss.elastic.co/t/can-i-add-aindexs-documents-aggregation-result-into-b-indexs-document/166274/1 "2019-01-30T07:08:59Z")

</div>

Hi. i'm using elasticsearch 6.4.1.

i was posted this question.

> [@Can i reindex aggregation's result to other index?](https://discuss.elastic.co/t/can-i-reindex-aggregations-result-to-other-index/166102):
>
> Hi. im using Elasticseacrh 6.4.1 i have a lot of logs. to visualize these, im using vega in Kibana. (there are nested objects) but logs are too many exist to aggregate and drawing grpah in vega. (request timeout occured) so, i decided to make other index to save summary information of the index's aggregation results. crontab (or scheduling job) will insert this summary information to new index. (near realtime aggregation summary) im refering ElasticSearch documents, and i saw 'reindex' f…

and @warkolm answered for me. thank you.

but i guess 'Rollup API' doesn't support 'Nested Aggregation'.  
([Rollup aggregation limitations | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-agg-limitations.html))

but i'm using complex query including various aggregation.

my request are composited to query/filter/terms aggregation, avg aggregation, nested aggregation, etc.

exactly what i want to do is

(1). query to A Index (including Nested Aggregation)

(2). add (1)'s result to B Index as each documents (B Index will have multiple documents)

(3). repeat this every 1 minute.  
(B Index's documents' date interval will be 1 minute)

(4). B Index's documents are composed to A Index's aggregation result.  
for example,  
doc1 : aggregation result about A Index at now -3m/m  
doc2 : aggregation result about A Index at now -2m/m  
doc3 : aggregation result about A Index at now -1m/m  
doc4 : aggregation result about A Index at now/m

(5). querying B Index and show the graph (Vega in Kibana)

when i saw 'Rollup API', i interested in 'crontab' string.

but, Rollup API doesn't save result as documents (not exactly, i guess this)  
and doesn't support 'Nested Aggregation'

so i saw 'Watcher API'.  
but my license doesn't support this yet, so i couldn't test this feature.

can i do this?

---

<div class="post-metadata">

### Author: ![teemoGod](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teemogod/32/40817_2.png) [@teemoGod](https://discuss.elastic.co/u/teemoGod)
#### Post date: [January 31, 2019, 9:50am UTC](https://discuss.elastic.co/t/can-i-add-aindexs-documents-aggregation-result-into-b-indexs-document/166274/2 "2019-01-31T09:50:21Z")

</div>

i solved this problem.

X-Pack's Watcher API can handle this issue.

- note  
i tested Watcher API via trial (30 days free to use advanced X Pack) License.  
if you want to use Watcher API, you must purchase license.  
in basic and opensource license cant handle this.  
if you cant purchase license, you will be using script (php, java, python, etc)

---

<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: [February 28, 2019, 9:50am UTC](https://discuss.elastic.co/t/can-i-add-aindexs-documents-aggregation-result-into-b-indexs-document/166274/3 "2019-02-28T09:50:25Z")

</div>

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