# \_timestamp

**URL:** https://discuss.elastic.co/t/-timestamp/11026
**Category:** Elasticsearch
**Created:** [March 5, 2013, 10:29pm UTC](https://discuss.elastic.co/t/-timestamp/11026 "2013-03-05T22:29:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![vinh](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vinh](https://discuss.elastic.co/u/vinh)
#### Post date: [March 5, 2013, 10:29pm UTC](https://discuss.elastic.co/t/-timestamp/11026/1 "2013-03-05T22:29:44Z")

</div>

When inserting docs, I store my own timestamp value in the default "\_timestamp" field. Then I search docs and fetch both "\_source" and "\_timestamp" fields. I notice that the value of \_source.\_timestamp correctly has my value. But, fields.\_timestamp is different.

Is ES maintaining \_timestamp in two different places, even if I am overriding it?

```
}, {
  "_index" : "myindex",
  "_type" : "message",
  "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
  "_score" : null, "_source" : {"_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","timestamp":1361672205131,"msg":"hello there"},
  "fields" : {
    "_timestamp" : 1361672211995
  },
  "sort" : [1361672211995]
} ]

```

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vinh](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vinh](https://discuss.elastic.co/u/vinh)
#### Post date: [March 5, 2013, 10:41pm UTC](https://discuss.elastic.co/t/-timestamp/11026/2 "2013-03-05T22:41:26Z")

</div>

Sorry, copy-paste error. The ES response is:

```
}, {
  "_index" : "myindex",
  "_type" : "message",
  "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
  "_score" : null, "_source" : {"_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","_timestamp":1361672205131,"msg":"hello there"},
  "fields" : {
    "_timestamp" : 1361672211995
  },
  "sort" : [1361672211995]
} ]

```

On Mar 5, 2013, at 2:29 PM, vinh [vinh@loggly.com](mailto:vinh@loggly.com) wrote:

> When inserting docs, I store my own timestamp value in the default "\_timestamp" field. Then I search docs and fetch both "\_source" and "\_timestamp" fields. I notice that the value of \_source.\_timestamp correctly has my value. But, fields.\_timestamp is different.
> 
> Is ES maintaining \_timestamp in two different places, even if I am overriding it?
> 
> ```
> }, {
> "_index" : "myindex",
> "_type" : "message",
> "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
> "_score" : null, "_source" : {"_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","timestamp":1361672205131,"msg":"hello there"},
> "fields" : {
> "_timestamp" : 1361672211995
> },
> "sort" : [1361672211995]
> } ]
> 
> ```

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [March 5, 2013, 10:41pm UTC](https://discuss.elastic.co/t/-timestamp/11026/3 "2013-03-05T22:41:31Z")

</div>

Did you enable the timestamp field in your mapping? It is not enabled by  
default. Also, your example shows the field as "timestamp" without the  
underscore. Is this correct? Your source should contain whatever was  
inserted.

--  
Ivan

On Tue, Mar 5, 2013 at 2:29 PM, vinh [vinh@loggly.com](mailto:vinh@loggly.com) wrote:

> When inserting docs, I store my own timestamp value in the default  
> "\_timestamp" field. Then I search docs and fetch both "\_source" and  
> "\_timestamp" fields. I notice that the value of \_source.\_timestamp  
> correctly has my value. But, fields.\_timestamp is different.
> 
> Is ES maintaining \_timestamp in two different places, even if I am  
> overriding it?
> 
> ```
> }, {
> "_index" : "myindex",
> "_type" : "message",
> "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
> "_score" : null, "_source" :
> 
> ```
> 
> {"\_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","timestamp":_1361672205131_,"msg":"hello  
> there"},  
> "fields" : {  
> "\_timestamp" : _1361672211995_  
> },  
> "sort" : [1361672211995]  
> } ]
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vinh](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vinh](https://discuss.elastic.co/u/vinh)
#### Post date: [March 5, 2013, 10:43pm UTC](https://discuss.elastic.co/t/-timestamp/11026/4 "2013-03-05T22:43:03Z")

</div>

My schema is:

{  
"template" : "\*",  
"settings": {  
"number\_of\_shards" : 5,  
"number\_of\_replicas" : 1  
},  
"mappings" : {  
"message" : {  
"\_source" : {"enabled" : true},  
"\_all" : {"enabled": false},  
"\_id" : {"index": "not\_analyzed", "store" : "yes"},  
"\_timestamp" : {"enabled" : true, "index" : "not\_analyzed", "store" : "yes"}  
}  
}  
}

On Mar 5, 2013, at 2:41 PM, vinh [vinh@loggly.com](mailto:vinh@loggly.com) wrote:

> Sorry, copy-paste error. The ES response is:
> 
> ```
> }, {
> "_index" : "myindex",
> "_type" : "message",
> "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
> "_score" : null, "_source" : {"_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","_timestamp":1361672205131,"msg":"hello there"},
> "fields" : {
> "_timestamp" : 1361672211995
> },
> "sort" : [1361672211995]
> } ]
> 
> ```
> 
> On Mar 5, 2013, at 2:29 PM, vinh [vinh@loggly.com](mailto:vinh@loggly.com) wrote:
> 
> > When inserting docs, I store my own timestamp value in the default "\_timestamp" field. Then I search docs and fetch both "\_source" and "\_timestamp" fields. I notice that the value of \_source.\_timestamp correctly has my value. But, fields.\_timestamp is different.
> > 
> > Is ES maintaining \_timestamp in two different places, even if I am overriding it?
> > 
> > ```
> > }, {
> > "_index" : "myindex",
> > "_type" : "message",
> > "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
> > "_score" : null, "_source" : {"_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","timestamp":1361672205131,"msg":"hello there"},
> > "fields" : {
> > "_timestamp" : 1361672211995
> > },
> > "sort" : [1361672211995]
> > } ]
> > 
> > ```

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [March 5, 2013, 10:47pm UTC](https://discuss.elastic.co/t/-timestamp/11026/5 "2013-03-05T22:47:39Z")

</div>

Have you tried without "index" : "not\_analyzed", "store" : "yes" ?

Jörg

Am 05.03.13 23:43, schrieb vinh:

> ```
> "_timestamp" : {"enabled" : true, "index" : "not_analyzed", 
> 
> ```
> 
> "store" : "yes"}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [March 5, 2013, 10:52pm UTC](https://discuss.elastic.co/t/-timestamp/11026/6 "2013-03-05T22:52:46Z")

</div>

I have never used the timestamp field, but I have seen peculiarities with  
the boost field.

From what I can tell from the documentation, the timestamp field is added  
automatically. Providing your own is conflicting with the internal version.  
And while I do not know all the details of the conflict resolution  
mechanism, my only advice would be to simply not get into the situation in  
the first place. Either you add the timestamp or let Elasticsearch do it.  
As you can see, maintaining your own is not difficult.

It appears that Elasticsearch is preserving the original in the source, but  
adding its own as the indexed field. The behavior seems ideal.

Cheers,  
Ivan

On Tue, Mar 5, 2013 at 2:47 PM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Have you tried without "index" : "not\_analyzed", "store" : "yes" ?
> 
> Jörg
> 
> Am 05.03.13 23:43, schrieb vinh:
> 
> ```
> "_timestamp" : {"enabled" : true, "index" : "not_analyzed", "store" :
> 
> ```
> 
> > "yes"}
> 
> --  
> 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](http://googlegroups.com)[elasticsearch%2Bunsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> .

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)
#### Post date: [March 5, 2013, 11:23pm UTC](https://discuss.elastic.co/t/-timestamp/11026/7 "2013-03-05T23:23:47Z")

</div>

Hey you can either set the timestamp value in your index request or extract  
it from the source. If you want to extract it from the source you have to  
tell ES where to find you timestamp field using path in your mapping as  
described here  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/timestamp-field.html).

It won't automatically use a \_timestamp field set in your source content.

On Tuesday, March 5, 2013 11:29:44 PM UTC+1, vinh wrote:

> When inserting docs, I store my own timestamp value in the default  
> "\_timestamp" field. Then I search docs and fetch both "\_source" and  
> "\_timestamp" fields. I notice that the value of \_source.\_timestamp  
> correctly has my value. But, fields.\_timestamp is different.
> 
> Is ES maintaining \_timestamp in two different places, even if I am  
> overriding it?
> 
> ```
> }, {
> "_index" : "myindex",
> "_type" : "message",
> "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
> "_score" : null, "_source" : 
> 
> ```
> 
> {"\_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","timestamp":_1361672205131_,"msg":"hello  
> there"},  
> "fields" : {  
> "\_timestamp" : _1361672211995_  
> },  
> "sort" : [1361672211995]  
> } ]

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vinh](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vinh](https://discuss.elastic.co/u/vinh)
#### Post date: [March 6, 2013, 6:34am UTC](https://discuss.elastic.co/t/-timestamp/11026/8 "2013-03-06T06:34:27Z")

</div>

Thanks Jorg,  
No luck without that setting. But I also need that setting, or else I can't sort on \_timestamp.  
-Vinh

On Mar 5, 2013, at 2:47 PM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Have you tried without "index" : "not\_analyzed", "store" : "yes" ?
> 
> Jörg
> 
> Am 05.03.13 23:43, schrieb vinh:
> 
> > "\_timestamp" : {"enabled" : true, "index" : "not\_analyzed", "store" : "yes"}
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![vinh](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vinh](https://discuss.elastic.co/u/vinh)
#### Post date: [March 6, 2013, 6:48am UTC](https://discuss.elastic.co/t/-timestamp/11026/9 "2013-03-06T06:48:05Z")

</div>

Thanks Benjamin,

I am currently setting the \_timestamp value in the request. I'm trying to avoid mapping/extracting it to another field in the source, to avoid needing two fields for the same value.

-Vinh

On Mar 5, 2013, at 3:23 PM, Benjamin Devèze [benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:

> Hey you can either set the timestamp value in your index request or extract it from the source. If you want to extract it from the source you have to tell ES where to find you timestamp field using path in your mapping as described here  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/timestamp-field.html).
> 
> It won't automatically use a \_timestamp field set in your source content.
> 
> On Tuesday, March 5, 2013 11:29:44 PM UTC+1, vinh wrote:  
> When inserting docs, I store my own timestamp value in the default "\_timestamp" field. Then I search docs and fetch both "\_source" and "\_timestamp" fields. I notice that the value of \_source.\_timestamp correctly has my value. But, fields.\_timestamp is different.
> 
> Is ES maintaining \_timestamp in two different places, even if I am overriding it?
> 
> ```
> }, {
> "_index" : "myindex",
> "_type" : "message",
> "_id" : "3c60f48b-7e28-11e2-8081-000c29c275f9",
> "_score" : null, "_source" : {"_id":"3c60f48b-7e28-11e2-8081-000c29c275f9","timestamp":1361672205131,"msg":"hello there"},
> "fields" : {
> "_timestamp" : 1361672211995
> },
> "sort" : [1361672211995]
> } ]
> 
> ```
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:48am UTC](https://discuss.elastic.co/t/-timestamp/11026/10 "2017-07-06T02:48:08Z")

</div>


