# Elasticsearch insert triggers

**URL:** https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860
**Category:** Elasticsearch
**Created:** [May 7, 2017, 7:52pm UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860 "2017-05-07T19:52:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![priyaraj](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@priyaraj](https://discuss.elastic.co/u/priyaraj)
#### Post date: [May 7, 2017, 7:52pm UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860/1 "2017-05-07T19:52:23Z")

</div>

Hi,  
I have a use case where when a certain document is indexed, based on the fields in the newly inserted document, I would like to index another document in a different index. The expected behavior is somewhat similar to an insert trigger in SQL Server. How can this be done? What are some of the options in Elasticsearch?  
Thanks for your help!

---

<div class="post-metadata">

### Author: ![priyaraj](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@priyaraj](https://discuss.elastic.co/u/priyaraj)
#### Post date: [May 16, 2017, 12:33am UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860/2 "2017-05-16T00:33:39Z")

</div>

Hi, I am looking for information on this still. Any help is greatly appreciated. When a document comes in, would like to do the following:

1. Search another index for certain documents based on a few fields of the incoming document
2. Then create a new document which is a "derived" document and index it into a another index
3. Proceed with indexing the current incoming document

I have looked at the ingest node custom processor plugin as one of the potential options but not sure if it is capable of doing something like this and what are some of the pitfalls to watch out for?  
Also is there another solution available?

Thanks  
Priya

---

<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: [May 16, 2017, 4:30am UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860/3 "2017-05-16T04:30:40Z")

</div>

The ingest node can as far as I know only modify the current document, not create new ones, so you will need to do this before you send the data to Elasticsearch.

---

<div class="post-metadata">

### Author: ![priyaraj](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@priyaraj](https://discuss.elastic.co/u/priyaraj)
#### Post date: [May 18, 2017, 3:34pm UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860/4 "2017-05-18T15:34:56Z")

</div>

Thank you for your reply. Sorry for the delay. Ingest pipeline is what I was thinking to implement for this. The pipeline could have a custom processor that would do this. Can you please confirm if this is a viable solution? Would exposing a custom REST API end point in elasticsearch an option too? If both can do this, is one preferred over another?

Thanks for your time.

---

<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: [May 18, 2017, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860/5 "2017-05-18T15:36:30Z")

</div>

I clarified my previous response as I now realised it was confusing.

---

<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: [June 15, 2017, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-insert-triggers/84860/6 "2017-06-15T15:36:46Z")

</div>

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