# Creation and update timestamps for each doc?

**URL:** <https://discuss.elastic.co/t/creation-and-update-timestamps-for-each-doc/93456>\
**Category:** Elasticsearch\
**Created:** [July 17, 2017, 9:08pm UTC](https://discuss.elastic.co/t/creation-and-update-timestamps-for-each-doc/93456 "2017-07-17T21:08:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [July 18, 2017, 9:39am UTC](https://discuss.elastic.co/t/creation-and-update-timestamps-for-each-doc/93456/2 "2017-07-18T09:39:10Z")

</div>

You could try to create an ingest pipeline for setting the created and updated timestamps, in a pipeline you can both add new document fields and modify old ones. Ref:

[https://www.elastic.co/guide/en/elasticsearch/reference/5.5/put-pipeline-api.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/put-pipeline-api.html)

You can create fairly complex scripts using the painless scripting language inside such pipelines. Here's an example of a pipeline we use at my company for setting the processing time on our documents:

{  
"description" : "Sets the document processingtime",  
"processors" : [  
{  
"script" : {  
"lang" : "painless",  
"inline" : "DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");\ndf.setTimeZone(TimeZone.getTimeZone("UTC"));\nDate date = new Date();\nctx.processingtime = df.format(date);"  
}  
}  
]  
}

It's fairly efficient too as we run millions of docs through this pipeline every day without any noticeable delays in our indexing.

Good luck!

---

_[View the full topic](https://discuss.elastic.co/t/creation-and-update-timestamps-for-each-doc/93456)._
