# Create new document on index and update a second document

**URL:** <https://discuss.elastic.co/t/create-new-document-on-index-and-update-a-second-document/194174>\
**Category:** Elasticsearch\
**Created:** [August 7, 2019, 8:00am UTC](https://discuss.elastic.co/t/create-new-document-on-index-and-update-a-second-document/194174 "2019-08-07T08:00:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grahams](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@grahams](https://discuss.elastic.co/u/grahams)\
**Post date:** [August 7, 2019, 8:00am UTC](https://discuss.elastic.co/t/create-new-document-on-index-and-update-a-second-document/194174/1 "2019-08-07T08:00:59Z")

</div>

Hi,

ES newbie here. Is it possible, say in an ingest pipeline, to store the document into one index and then take some of the fields and update a second index. For example an order document would be stored and a customer document in another index would have its order count and last\_order date updated?

Or store some of the document fields in one index and other fields in a second index effectively creating 2 documents from one?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 7, 2019, 8:14am UTC](https://discuss.elastic.co/t/create-new-document-on-index-and-update-a-second-document/194174/2 "2019-08-07T08:14:39Z")

</div>

hey,

an ingest pipeline can change a document, but in the end it will always only index a single document. I think it makes more sense to index two documents, using the bulk API, one and index operation and one an update operation.

Another way could be to trigger a reindex operation to regularly query for changes in the last n minutes, which uses a script to only store parts of the documents in the other index.

Maybe (just guessing though) the new [data frames feature](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/ml-dataframes.html) might be worth a look as well.

--Alex

---

<div class="post-metadata">

**Author:** ![grahams](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@grahams](https://discuss.elastic.co/u/grahams)\
**Post date:** [August 7, 2019, 8:41am UTC](https://discuss.elastic.co/t/create-new-document-on-index-and-update-a-second-document/194174/3 "2019-08-07T08:41:36Z")

</div>

Thanks Alex, that was what I had been assuming but just wanted to make sure there wasn't some way of doing this directly on ingest.

---

<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:** [September 4, 2019, 8:41am UTC](https://discuss.elastic.co/t/create-new-document-on-index-and-update-a-second-document/194174/4 "2019-09-04T08:41:43Z")

</div>

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