# Detect insert/update for document into ES plugin?

**URL:** <https://discuss.elastic.co/t/detect-insert-update-for-document-into-es-plugin/22430>\
**Category:** Elasticsearch\
**Created:** [February 27, 2015, 10:51am UTC](https://discuss.elastic.co/t/detect-insert-update-for-document-into-es-plugin/22430 "2015-02-27T10:51:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![plunger](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@plunger](https://discuss.elastic.co/u/plunger)\
**Post date:** [February 27, 2015, 10:51am UTC](https://discuss.elastic.co/t/detect-insert-update-for-document-into-es-plugin/22430/1 "2015-02-27T10:51:48Z")

</div>

Guys, I am working on very simple ES plugin in common with "elasticsearch-mapper-attachments" plugin.  
My goal is to perform some analysis on the document content, in ES index stage, and output the result of the analysis into JSON structure.

All works pretty fine - thank you ES team.

In order to perform analysis the document on index stage I use regular implementation of **AbstractFieldMapper** and do my work in **parse(ParseContext context)** method. I see that #parse method is invoked as consequence of 2 events: insert document and update document.

As **plugin optimisation** I would like to run document analysis only when the new document is created. If the document is updated I would like to bypass the logic into #parse method.  
My data is coming from river.

So the **question** in the front of me is - how I can detect the root event of the #parse method invocation?

---

<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, 12:29am UTC](https://discuss.elastic.co/t/detect-insert-update-for-document-into-es-plugin/22430/2 "2017-07-06T00:29:31Z")

</div>


