# Update a document in a watcher

**URL:** <https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066>\
**Category:** Elasticsearch\
**Created:** [June 3, 2019, 11:21pm UTC](https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066 "2019-06-03T23:21:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafa\_hassan](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mostafa\_hassan](https://discuss.elastic.co/u/mostafa_hassan)\
**Post date:** [June 3, 2019, 11:21pm UTC](https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066/1 "2019-06-03T23:21:39Z")

</div>

Continuing the discussion from [Is it possible to update a document in watcher](https://discuss.elastic.co/t/is-it-possible-to-update-a-document-in-watcher/147136):

The proposed answer shows how to CREATE a document using index action, but the real question is how to update a document from a watcher.

The only way that I can think of is to CREATE a document and copy all fields including the id except the one I wanted to update. Is there a better?

---

<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:** [June 7, 2019, 11:58am UTC](https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066/2 "2019-06-07T11:58:17Z")

</div>

would it work for you to retrieve the document as part of the input and then save the whole document in the `index` action (and modify before saving), which basically is an update?

Another alternative might be to use the webhook action and call the update API yourself, even though that is a bit more of a hack it might work in your case.

---

<div class="post-metadata">

**Author:** ![mostafa\_hassan](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mostafa\_hassan](https://discuss.elastic.co/u/mostafa_hassan)\
**Post date:** [June 7, 2019, 1:54pm UTC](https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066/3 "2019-06-07T13:54:05Z")

</div>

> [@spinscale](#):
>
> would it work for you to retrieve the document as part of the input and then save the whole document in the `index` action (and modify before saving), which basically is an update?

Yes, that is what I'm currently doing. Based on your reply, it looks like this is the best way, as the other option is

> [@spinscale](#):
>
> a bit more of a hack

right?

---

<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:** [June 7, 2019, 2:08pm UTC](https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066/4 "2019-06-07T14:08:22Z")

</div>

indeed, I'd go with the first approach then.

---

<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, 2019, 2:08pm UTC](https://discuss.elastic.co/t/update-a-document-in-a-watcher/184066/5 "2019-07-05T14:08:27Z")

</div>

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