# Externally-provided timestamp being overridden

**URL:** https://discuss.elastic.co/t/externally-provided-timestamp-being-overridden/16834
**Category:** Elasticsearch
**Created:** [April 6, 2014, 5:18pm UTC](https://discuss.elastic.co/t/externally-provided-timestamp-being-overridden/16834 "2014-04-06T17:18:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Sokolov](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Michael\_Sokolov](https://discuss.elastic.co/u/Michael_Sokolov)
#### Post date: [April 6, 2014, 5:18pm UTC](https://discuss.elastic.co/t/externally-provided-timestamp-being-overridden/16834/1 "2014-04-06T17:18:55Z")

</div>

I need to be able to provide timestamps that will be preserved by ES. I'm  
using the \_timestamp field (although perhaps I shouldn't, because) it seems  
that the values I provide are being ignored, and the current date-time is  
being inserted instead. My mapping configuration looks like this:

dynamic: strict

\_source:  
enabled: false

\_all:  
enabled: false

\_timestamp:  
type: date  
enabled: true  
index: not\_analyzed  
store: true

properties:  
...

I've tried providing the times as longs, as longs converted to strings, as  
ISO-formatted date-times (YYYYMMDDThhmmss.SSS), but nothing seems to have  
any effect -- I might as well provide 0.

I'm inserting documents using the Java client API by creating a Map, with  
key="\_timestamp" and values as described above.

Has anybody run across this before? It seems like a very standard use case  
if you want to keep a consistent timestamp across a cluster, or in any way  
copy documents without updating their timestamps.

-Mike

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bc9de57c-e20d-45bc-8fb1-4537177e277b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bc9de57c-e20d-45bc-8fb1-4537177e277b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Michael\_Sokolov](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Michael\_Sokolov](https://discuss.elastic.co/u/Michael_Sokolov)
#### Post date: [April 6, 2014, 5:27pm UTC](https://discuss.elastic.co/t/externally-provided-timestamp-being-overridden/16834/2 "2014-04-06T17:27:17Z")

</div>

quick follow-up -- of course using my own long-valued field seems to work  
just fine, but I would still like to understand what's going on here. It  
might be nice to have the internally-generated behavior as a fallback?

On Sunday, April 6, 2014 1:18:55 PM UTC-4, Michael Sokolov wrote:

> I need to be able to provide timestamps that will be preserved by ES. I'm  
> using the \_timestamp field (although perhaps I shouldn't, because) it seems  
> that the values I provide are being ignored, and the current date-time is  
> being inserted instead. My mapping configuration looks like this:
> 
> dynamic: strict
> 
> \_source:  
> enabled: false
> 
> \_all:  
> enabled: false
> 
> \_timestamp:  
> type: date  
> enabled: true  
> index: not\_analyzed  
> store: true
> 
> properties:  
> ...
> 
> I've tried providing the times as longs, as longs converted to strings, as  
> ISO-formatted date-times (YYYYMMDDThhmmss.SSS), but nothing seems to have  
> any effect -- I might as well provide 0.
> 
> I'm inserting documents using the Java client API by creating a Map, with  
> key="\_timestamp" and values as described above.
> 
> Has anybody run across this before? It seems like a very standard use  
> case if you want to keep a consistent timestamp across a cluster, or in any  
> way copy documents without updating their timestamps.
> 
> -Mike

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b948a29d-92af-45c4-9491-97e9b6495615%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b948a29d-92af-45c4-9491-97e9b6495615%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [April 9, 2014, 2:16pm UTC](https://discuss.elastic.co/t/externally-provided-timestamp-being-overridden/16834/3 "2014-04-09T14:16:28Z")

</div>

From the Java API, you should be able to do something like:

client.prepareIndex().setTimestamp(blah)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/646894ff-6581-43d9-a890-e701b4f29b86%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/646894ff-6581-43d9-a890-e701b4f29b86%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 1:37am UTC](https://discuss.elastic.co/t/externally-provided-timestamp-being-overridden/16834/4 "2017-07-06T01:37:16Z")

</div>


