# Is there any way to enable versioning or concurrency control of documents based on a particular field? (Timestamp field)

**URL:** <https://discuss.elastic.co/t/is-there-any-way-to-enable-versioning-or-concurrency-control-of-documents-based-on-a-particular-field-timestamp-field/215388>\
**Category:** Elasticsearch\
**Created:** [January 16, 2020, 8:33pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-enable-versioning-or-concurrency-control-of-documents-based-on-a-particular-field-timestamp-field/215388 "2020-01-16T20:33:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![perahimi](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@perahimi](https://discuss.elastic.co/u/perahimi)\
**Post date:** [January 16, 2020, 8:33pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-enable-versioning-or-concurrency-control-of-documents-based-on-a-particular-field-timestamp-field/215388/1 "2020-01-16T20:33:40Z")

</div>

Hello,

I am currently working with catalog data that is coming in hourly in our pipeline. This is an example of how the written source document might look like.

```
{
    "name": "Hoodie",
    "sku": "123",
    "timeStamp": "2020-01-16T17:39:23Z",
    "price": 20
}

```

Lets say there is an issue and old data happens to come in later than the new data for whatever reason. Is there any way to tell ElasticSearch to look at the timeStamp field first before writing the document?

For example, lets say the document above was written, and a few mins later this document comes in...

```
{
    "name": "Hoodie",
    "sku": "123",
    "timeStamp": "2019-12-31T17:39:23Z",
    "price": 15
}

```

I obviously wouldn't want this to overwrite the more recent one. Is there a way to let ES know to version the documents by a particular field? I looked into using a script, but i can't figure out a way to have access to both the \_source context and the incoming document context.

---

<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:** [February 13, 2020, 8:33pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-enable-versioning-or-concurrency-control-of-documents-based-on-a-particular-field-timestamp-field/215388/2 "2020-02-13T20:33:46Z")

</div>

Closed on February 13, 2020, 8:33pm UTC

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