# Storing the diff of two fields in a new field

**URL:** <https://discuss.elastic.co/t/storing-the-diff-of-two-fields-in-a-new-field/175771>\
**Category:** Elasticsearch\
**Created:** [April 8, 2019, 6:54am UTC](https://discuss.elastic.co/t/storing-the-diff-of-two-fields-in-a-new-field/175771 "2019-04-08T06:54:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sai\_Birada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sai_birada/32/142367_2.png) [@Sai\_Birada](https://discuss.elastic.co/u/Sai_Birada)\
**Post date:** [April 8, 2019, 6:54am UTC](https://discuss.elastic.co/t/storing-the-diff-of-two-fields-in-a-new-field/175771/1 "2019-04-08T06:54:42Z")

</div>

I am trying to store some json data generated after running some api call, into elasticsearch, and my documents look like this.

> { "host" : "hostname", "time" : "timestamp", "command" : "command being run", "data\_before" : "some json set of fields and thier values before running command", "data\_after" : "same json set of fields with updated values after running command" }

My requirement is to loop through all the fields like data\_before.\* and compare them with their corresponding fields in data\_after.\* and store / ingest only those fields which are modified.

My use case is to see, which fields of my dataset are actually modified at a given point of time (one or two out of some 100+ fields will only be modified usually), storing/ingesting the entire dataset as data\_before and data\_after does not look feasible.

Any suggestions on how I can get this done at ingestNode level will be very helpful.

---

<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 6, 2019, 7:02am UTC](https://discuss.elastic.co/t/storing-the-diff-of-two-fields-in-a-new-field/175771/2 "2019-05-06T07:02:21Z")

</div>

Closed on May 6, 2019, 7:02am UTC

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