# Trigger on insert to index

**URL:** <https://discuss.elastic.co/t/trigger-on-insert-to-index/229113>\
**Category:** Elasticsearch\
**Created:** [April 21, 2020, 5:51pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113 "2020-04-21T17:51:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![somethingcool](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@somethingcool](https://discuss.elastic.co/u/somethingcool)\
**Post date:** [April 21, 2020, 5:51pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/1 "2020-04-21T17:51:45Z")

</div>

Hello,

I am using elasticsearch 6.8 and I couldn't find anything directly to this question, but was curious to know if it is possible to call an external python script after the insert of data into an index.

If it is possible, could someone point me to the resources so that I could learn more about the available tools to make that happen.

---

<div class="post-metadata">

**Author:** ![whatgeorgemade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whatgeorgemade/32/103246_2.png) [@whatgeorgemade](https://discuss.elastic.co/u/whatgeorgemade)\
**Post date:** [April 21, 2020, 6:22pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/2 "2020-04-21T18:22:56Z")

</div>

This isn't currently possible.

It's functionality that would likely be available once the Changes API is released but that's a long, long way off.

---

<div class="post-metadata">

**Author:** ![somethingcool](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@somethingcool](https://discuss.elastic.co/u/somethingcool)\
**Post date:** [April 21, 2020, 6:28pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/3 "2020-04-21T18:28:51Z")

</div>

where do you see info on that api?

---

<div class="post-metadata">

**Author:** ![whatgeorgemade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whatgeorgemade/32/103246_2.png) [@whatgeorgemade](https://discuss.elastic.co/u/whatgeorgemade)\
**Post date:** [April 21, 2020, 6:30pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/4 "2020-04-21T18:30:59Z")

</div>

> <https://github.com/elastic/elasticsearch/issues/1242>
>
> There should be an integration point for ES and external application where the external applications should be notified of any document...

The issue was raised in 2011 and is still being discussed, so it's not coming any time soon!

---

<div class="post-metadata">

**Author:** ![somethingcool](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@somethingcool](https://discuss.elastic.co/u/somethingcool)\
**Post date:** [April 21, 2020, 6:33pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/5 "2020-04-21T18:33:31Z")

</div>

Okay thank you for that info, but is it not possible to achieve something similar with a trigger or watcher?

So if data is inserted to some index, after that operation I can trigger some external command?

---

<div class="post-metadata">

**Author:** ![whatgeorgemade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whatgeorgemade/32/103246_2.png) [@whatgeorgemade](https://discuss.elastic.co/u/whatgeorgemade)\
**Post date:** [April 21, 2020, 6:37pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/6 "2020-04-21T18:37:05Z")

</div>

There's no way for elasticsearch to notify you of a document being indexed.

The only way you could do this currently is to only index documents from one single place, then deal with notifying other services once the index operation returns.

---

<div class="post-metadata">

**Author:** ![somethingcool](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@somethingcool](https://discuss.elastic.co/u/somethingcool)\
**Post date:** [April 21, 2020, 6:44pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/7 "2020-04-21T18:44:55Z")

</div>

So a watcher doesnt do something similar ?

---

<div class="post-metadata">

**Author:** ![somethingcool](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@somethingcool](https://discuss.elastic.co/u/somethingcool)\
**Post date:** [April 21, 2020, 6:46pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/8 "2020-04-21T18:46:41Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/current/actions-webhook.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/actions-webhook.html)

---

<div class="post-metadata">

**Author:** ![whatgeorgemade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whatgeorgemade/32/103246_2.png) [@whatgeorgemade](https://discuss.elastic.co/u/whatgeorgemade)\
**Post date:** [April 21, 2020, 7:39pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/9 "2020-04-21T19:39:31Z")

</div>

A watcher is a way to run periodic queries and send alerts if the results match some criteria. It won't tell you when a document is indexed.

---

<div class="post-metadata">

**Author:** ![somethingcool](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@somethingcool](https://discuss.elastic.co/u/somethingcool)\
**Post date:** [April 21, 2020, 8:04pm UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/10 "2020-04-21T20:04:34Z")

</div>

Even if you perform some aggregate?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 22, 2020, 5:00am UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/11 "2020-04-22T05:00:32Z")

</div>

Easiest way to to this is to e.g. write to a message queue when you index data and the read from there. Watcher will not help here.

---

<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:** [May 20, 2020, 5:00am UTC](https://discuss.elastic.co/t/trigger-on-insert-to-index/229113/12 "2020-05-20T05:00:34Z")

</div>

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