# How to do index multiple docs in watcher action

**URL:** <https://discuss.elastic.co/t/how-to-do-index-multiple-docs-in-watcher-action/47283>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [April 13, 2016, 5:00pm UTC](https://discuss.elastic.co/t/how-to-do-index-multiple-docs-in-watcher-action/47283 "2016-04-13T17:00:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lilu1](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@lilu1](https://discuss.elastic.co/u/lilu1)\
**Post date:** [April 13, 2016, 5:00pm UTC](https://discuss.elastic.co/t/how-to-do-index-multiple-docs-in-watcher-action/47283/1 "2016-04-13T17:00:02Z")

</div>

I have a watcher. I want every time when the watcher got triggered, some (maybe 0, 1 or more than 1) documents can be inserted into an index based on the aggregation result.

The action looks like below in my watcher test, but it does not work.  
I want to insert 2 docs: {foo: bar1}, {foo: bar2}  
There is no example for [https://www.elastic.co/guide/en/watcher/current/actions.html#anatomy-actions-index-multi-doc-support](https://www.elastic.co/guide/en/watcher/current/actions.html#anatomy-actions-index-multi-doc-support)

Thanks so much !

"actions": {  
"put\_daily\_agg": {  
"transform" : {  
"script" : "return \_doc : [foo : bar1, foo: bar2]"  
},  
"index": {  
"index" : "my-index",  
"doc\_type" : "my-type"

```
    }
}
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 14, 2016, 2:03pm UTC](https://discuss.elastic.co/t/how-to-do-index-multiple-docs-in-watcher-action/47283/2 "2016-04-14T14:03:38Z")

</div>

Hey there,

check the documentation about [index multiple docs](https://www.elastic.co/guide/en/watcher/current/actions.html#anatomy-actions-index-multi-doc-support) in combination with a transform as well as this [discussion in this forum](https://discuss.elastic.co/t/re-indexing-an-aggregation-for-later-use/45012/4?u=spinscale), which yields an example.

That should help you to get up and running!

--Alex

---

<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 6, 2017, 1:45pm UTC](https://discuss.elastic.co/t/how-to-do-index-multiple-docs-in-watcher-action/47283/3 "2017-07-06T13:45:57Z")

</div>


