# Extra processing during every indexing action

**URL:** <https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272>\
**Category:** Elasticsearch\
**Created:** [April 22, 2017, 10:49am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272 "2017-04-22T10:49:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sachin\_Shaju](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@Sachin\_Shaju](https://discuss.elastic.co/u/Sachin_Shaju)\
**Post date:** [April 22, 2017, 10:49am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/1 "2017-04-22T10:49:18Z")

</div>

I would like to have a custom behavior like _performing some action/processing_ on(before/after) every index request to ES and update a field of inserted document after processing. I've done some research on Watcher component in ES and custom plugin development for the same. But I couldn't find suited options or methods for this. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [April 22, 2017, 3:00pm UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/2 "2017-04-22T15:00:15Z")

</div>

What you're asking is a bit too generic to answer outright. Can you give some more insight into what specifically you're trying to do?

There are a number of potential options that may fit, depending on what that custom action or processing is. One option may be ingest node ([https://www.elastic.co/guide/en/elasticsearch/reference/5.3/ingest.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/ingest.html)) which has a number of processors already built in ([https://www.elastic.co/guide/en/elasticsearch/reference/5.3/ingest-processors.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/ingest-processors.html)). If it's not one of the existing processors, it's possible we may be adding one in the future that does what you're looking for, and it's nice to be able to hear what people are trying to do. If not, it may be possible to build your own ingest processor (see [https://www.elastic.co/blog/writing-your-own-ingest-processor-for-elasticsearch](https://www.elastic.co/blog/writing-your-own-ingest-processor-for-elasticsearch) for information on that). It also may be possible to use a component before indexing into elasticsearch, e.g. Logstash, to do the processing.

---

<div class="post-metadata">

**Author:** ![Sachin\_Shaju](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@Sachin\_Shaju](https://discuss.elastic.co/u/Sachin_Shaju)\
**Post date:** [April 24, 2017, 4:33am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/3 "2017-04-24T04:33:52Z")

</div>

@shanec : We would like to have a field like _isProcessed_ initially set to false. After the indexing we would like to save original file that is indexed to a remote storage and do some other processing and update that field afterwards as true. We would like to do this for all the indexing to the cluster. Would like to know ingest node is the option here. Or any suitable options ?

---

<div class="post-metadata">

**Author:** ![Sachin\_Shaju](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@Sachin\_Shaju](https://discuss.elastic.co/u/Sachin_Shaju)\
**Post date:** [April 24, 2017, 8:03am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/4 "2017-04-24T08:03:13Z")

</div>

@shanec : there any way we can set an ingest processor /pipeline config for all indices in it ? Or at least set it as a setting during the index creation to use it on every index request ?

---

<div class="post-metadata">

**Author:** ![Sachin\_Shaju](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@Sachin\_Shaju](https://discuss.elastic.co/u/Sachin_Shaju)\
**Post date:** [April 24, 2017, 8:33am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/5 "2017-04-24T08:33:42Z")

</div>

@dadoonet : Any help or suggestions on this ?

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [April 24, 2017, 4:04pm UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/6 "2017-04-24T16:04:39Z")

</div>

If you're trying to actually do something like move a file around, I'd recommend you do this outside of Elasticsearch and in an upstream process. Otherwise you have to give every Elasticsearch node access to wherever the files come from / go to, including dealing with java security manager issues, etc. Elasticsearch isn't really meant for that. So I'd do that business logic in an upstream process and then use the [`_update` API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html) to update the `isProcessed` field after you've finished doing whatever you need to do.

---

<div class="post-metadata">

**Author:** ![Sachin\_Shaju](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@Sachin\_Shaju](https://discuss.elastic.co/u/Sachin_Shaju)\
**Post date:** [April 25, 2017, 6:05am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/7 "2017-04-25T06:05:21Z")

</div>

Ok. thank you for your suggestion. 🙂

---

<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 23, 2017, 6:13am UTC](https://discuss.elastic.co/t/extra-processing-during-every-indexing-action/83272/8 "2017-05-23T06:13:59Z")

</div>

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