# How to insert evaluated some specific documents results into another elasticsearch index using watcher actions?

**URL:** <https://discuss.elastic.co/t/how-to-insert-evaluated-some-specific-documents-results-into-another-elasticsearch-index-using-watcher-actions/117969>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [February 1, 2018, 8:45am UTC](https://discuss.elastic.co/t/how-to-insert-evaluated-some-specific-documents-results-into-another-elasticsearch-index-using-watcher-actions/117969 "2018-02-01T08:45:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [February 1, 2018, 8:45am UTC](https://discuss.elastic.co/t/how-to-insert-evaluated-some-specific-documents-results-into-another-elasticsearch-index-using-watcher-actions/117969/1 "2018-02-01T08:45:26Z")

</div>

Hello Folks,

I want to insert evaluated documents on the basis of written condition in a separate elastic-search index other than .watcher-history using watcher Action . during this process i also want to associate some custom field & value to tag the documents.

Basically, I don't want all the unnecessary fields which ".watcher-history-\*" index have. I want to push only original record & some custom field and values to tag them.

I will appreciate any small example in this direction.

-- Yash

---

<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:** [February 7, 2018, 8:48am UTC](https://discuss.elastic.co/t/how-to-insert-evaluated-some-specific-documents-results-into-another-elasticsearch-index-using-watcher-actions/117969/2 "2018-02-07T08:48:43Z")

</div>

You need to use a [transform](https://www.elastic.co/guide/en/x-pack/6.1/transform-script.html) inside of your `index` action to create the document structure you want. Like this

```auto
{
  "transform" : {
    "script" : "return ['time' : ctx.trigger.scheduled_time]" 
  }
}

```

Note, if you create a `_doc` array, you can also index multiple documents within a single [index action](https://www.elastic.co/guide/en/x-pack/6.1/actions-index.html#anatomy-actions-index-multi-doc-support).

---

<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:** [March 7, 2018, 8:48am UTC](https://discuss.elastic.co/t/how-to-insert-evaluated-some-specific-documents-results-into-another-elasticsearch-index-using-watcher-actions/117969/3 "2018-03-07T08:48:52Z")

</div>

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