# Need nodejs listener/Observer to detect new document in the index

**URL:** <https://discuss.elastic.co/t/need-nodejs-listener-observer-to-detect-new-document-in-the-index/356940>\
**Category:** Elasticsearch\
**Created:** [April 8, 2024, 5:52am UTC](https://discuss.elastic.co/t/need-nodejs-listener-observer-to-detect-new-document-in-the-index/356940 "2024-04-08T05:52:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brijeshp.sdei](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@brijeshp.sdei](https://discuss.elastic.co/u/brijeshp.sdei)\
**Post date:** [April 8, 2024, 5:52am UTC](https://discuss.elastic.co/t/need-nodejs-listener-observer-to-detect-new-document-in-the-index/356940/1 "2024-04-08T05:52:28Z")

</div>

Please help me to detect addition of new document in the elasticsearch (@elastic/elasticsearch nodejs plugin) (from logstash) and have to trigger javascript function

---

<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 8, 2024, 6:10am UTC](https://discuss.elastic.co/t/need-nodejs-listener-observer-to-detect-new-document-in-the-index/356940/2 "2024-04-08T06:10:50Z")

</div>

As far as I know that is not possible. You can however have an ingest pipeline run for each inserted document which will allow you to modify the document. Another option might be do do this in Logstash before ingesting the document. What is it you are looking to achieve using this function?

---

<div class="post-metadata">

**Author:** ![brijeshp.sdei](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@brijeshp.sdei](https://discuss.elastic.co/u/brijeshp.sdei)\
**Post date:** [April 8, 2024, 6:21am UTC](https://discuss.elastic.co/t/need-nodejs-listener-observer-to-detect-new-document-in-the-index/356940/3 "2024-04-08T06:21:45Z")

</div>

Hi @Christian_Dahlqvist thanks for prompt response. Though I need to implement listener for record insert & update in the elasticsearch index in my node js application to sent acknowledgment/message in realtime. Please suggest on this.

---

<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 8, 2024, 6:24am UTC](https://discuss.elastic.co/t/need-nodejs-listener-observer-to-detect-new-document-in-the-index/356940/4 "2024-04-08T06:24:08Z")

</div>

As far as I know there is no support for this in Elasticsearch so you may need to address this at the point when you are indexing the data, e.g. through custom Logstash config or a custom version of the Elasticsearch output plugin.
