# Timestamp

**URL:** <https://discuss.elastic.co/t/timestamp/4529>\
**Category:** Elasticsearch\
**Created:** [June 2, 2011, 5:59am UTC](https://discuss.elastic.co/t/timestamp/4529 "2011-06-02T05:59:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre1/32/3217_2.png) [@Andre1](https://discuss.elastic.co/u/Andre1)\
**Post date:** [June 2, 2011, 5:59am UTC](https://discuss.elastic.co/t/timestamp/4529/1 "2011-06-02T05:59:51Z")

</div>

Hi guys,

I would like to add a creation date to every JSON document that I add  
to the index.  
How would I do that?

Thanks,

Andre

---

<div class="post-metadata">

**Author:** ![Weiwei\_Wang](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@Weiwei\_Wang](https://discuss.elastic.co/u/Weiwei_Wang)\
**Post date:** [June 2, 2011, 7:19am UTC](https://discuss.elastic.co/t/timestamp/4529/2 "2011-06-02T07:19:09Z")

</div>

try  
curl -XPOST '[http://localhost:9200/index/type](http://localhost:9200/index/type)' -d '{"create":'$  
(date)'}'

On Jun 2, 1:59 pm, Andre [andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) wrote:

> Hi guys,
> 
> I would like to add a creation date to every JSON document that I add  
> to the index.  
> How would I do that?
> 
> Thanks,
> 
> Andre

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 2, 2011, 7:44am UTC](https://discuss.elastic.co/t/timestamp/4529/3 "2011-06-02T07:44:14Z")

</div>

You will need to add the timestamp yourself. We can add a special field, something like \_timestamp that gets automatically added by elasticsearch, the problem with that is the fact that you will need to make sure the different machines in the cluster are sync'ed time wise.

On Thursday, June 2, 2011 at 10:19 AM, Weiwei Wang wrote:

> try  
> curl -XPOST '[http://localhost:9200/index/type](http://localhost:9200/index/type)' -d '{"create":'$  
> (date)'}'
> 
> On Jun 2, 1:59 pm, Andre \<[andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> 
> > Hi guys,
> > 
> > I would like to add a creation date to every JSON document that I add  
> > to the index.  
> > How would I do that?
> > 
> > Thanks,
> > 
> > Andre

---

<div class="post-metadata">

**Author:** ![Andre1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre1/32/3217_2.png) [@Andre1](https://discuss.elastic.co/u/Andre1)\
**Post date:** [June 2, 2011, 10:45pm UTC](https://discuss.elastic.co/t/timestamp/4529/4 "2011-06-02T22:45:43Z")

</div>

Weiwei's example,

C:\elasticsearch-0.16.2\bin\>curl -XPOST [http://localhost:9200/twitter/user/dean](http://localhost:9200/twitter/user/dean)  
-d "{"user": "dean", "mydate" : "$(date)"}

is not working for, the index shows

{ "\_index": "twitter", "\_type": "user", "\_id": "dean", "\_score": 1,  
"\_source": { "user": "dean", "mydate": "$(date)" } }

Any ideas?

On Jun 2, 5:19 pm, Weiwei Wang [ww.wang...@gmail.com](mailto:ww.wang...@gmail.com) wrote:

> try  
> curl -XPOST '[http://localhost:9200/index/type'-d](http://localhost:9200/index/type'-d) '{"create":'$  
> (date)'}'
> 
> On Jun 2, 1:59 pm, Andre [andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) wrote:
> 
> > Hi guys,
> 
> > I would like to add a creation date to every JSON document that I add  
> > to the index.  
> > How would I do that?
> 
> > Thanks,
> 
> > Andre

---

<div class="post-metadata">

**Author:** ![Andre1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre1/32/3217_2.png) [@Andre1](https://discuss.elastic.co/u/Andre1)\
**Post date:** [June 2, 2011, 10:48pm UTC](https://discuss.elastic.co/t/timestamp/4529/5 "2011-06-02T22:48:30Z")

</div>

Thanks, all my servers a synced to a time server. How easy is it to  
add a special field like like \_timestamp?

On Jun 2, 5:44 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> You will need to add the timestamp yourself. We can add a special field, something like \_timestamp that gets automatically added by elasticsearch, the problem with that is the fact that you will need to make sure the different machines in the cluster are sync'ed time wise.
> 
> On Thursday, June 2, 2011 at 10:19 AM, Weiwei Wang wrote:
> 
> > try  
> > curl -XPOST '[http://localhost:9200/index/type'-d](http://localhost:9200/index/type'-d) '{"create":'$  
> > (date)'}'
> 
> > On Jun 2, 1:59 pm, Andre \<[andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > 
> > > Hi guys,
> 
> > > I would like to add a creation date to every JSON document that I add  
> > > to the index.  
> > > How would I do that?
> 
> > > Thanks,
> 
> > > Andre

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 2, 2011, 10:49pm UTC](https://discuss.elastic.co/t/timestamp/4529/6 "2011-06-02T22:49:40Z")

</div>

He ment that you will pass the date itself, preferable as an ISO format. Its not too difficult to add a timestamp field, as long as clocks are in sync. I think there is already an issue for that.

On Friday, June 3, 2011 at 1:48 AM, Andre wrote:

> Thanks, all my servers a synced to a time server. How easy is it to  
> add a special field like like \_timestamp?
> 
> On Jun 2, 5:44 pm, Shay Banon \<[shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) ([http://elasticsearch.com](http://elasticsearch.com))\> wrote:
> 
> > You will need to add the timestamp yourself. We can add a special field, something like \_timestamp that gets automatically added by elasticsearch, the problem with that is the fact that you will need to make sure the different machines in the cluster are sync'ed time wise.
> > 
> > On Thursday, June 2, 2011 at 10:19 AM, Weiwei Wang wrote:
> > 
> > > try  
> > > curl -XPOST '[http://localhost:9200/index/type'-d](http://localhost:9200/index/type'-d) '{"create":'$  
> > > (date)'}'
> > 
> > > On Jun 2, 1:59 pm, Andre \<[andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > 
> > > > Hi guys,
> > 
> > > > I would like to add a creation date to every JSON document that I add  
> > > > to the index.  
> > > > How would I do that?
> > 
> > > > Thanks,
> > 
> > > > Andre

---

<div class="post-metadata">

**Author:** ![Andre1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre1/32/3217_2.png) [@Andre1](https://discuss.elastic.co/u/Andre1)\
**Post date:** [June 3, 2011, 12:22am UTC](https://discuss.elastic.co/t/timestamp/4529/7 "2011-06-03T00:22:23Z")

</div>

Ah, ok thanks.

What about a scripting feature in the input JSON? Do you think this  
makes sense?

On Jun 3, 8:49 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> He ment that you will pass the date itself, preferable as an ISO format. Its not too difficult to add a timestamp field, as long as clocks are in sync. I think there is already an issue for that.
> 
> On Friday, June 3, 2011 at 1:48 AM, Andre wrote:
> 
> > Thanks, all my servers a synced to a time server. How easy is it to  
> > add a special field like like \_timestamp?
> 
> > On Jun 2, 5:44 pm, Shay Banon \<[shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) ([http://elasticsearch.com](http://elasticsearch.com))\> wrote:
> > 
> > > You will need to add the timestamp yourself. We can add a special field, something like \_timestamp that gets automatically added by elasticsearch, the problem with that is the fact that you will need to make sure the different machines in the cluster are sync'ed time wise.
> 
> > > On Thursday, June 2, 2011 at 10:19 AM, Weiwei Wang wrote:
> > > 
> > > > try  
> > > > curl -XPOST '[http://localhost:9200/index/type'-d'](http://localhost:9200/index/type'-d'){"create":'$  
> > > > (date)'}'
> 
> > > > On Jun 2, 1:59 pm, Andre \<[andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > 
> > > > > Hi guys,
> 
> > > > > I would like to add a creation date to every JSON document that I add  
> > > > > to the index.  
> > > > > How would I do that?
> 
> > > > > Thanks,
> 
> > > > > Andre

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 3, 2011, 12:33am UTC](https://discuss.elastic.co/t/timestamp/4529/8 "2011-06-03T00:33:58Z")

</div>

In what sense? One thing to note is that elasticsearch pull parse the json, there is no in memory representation of it. Things that munge the json before being indexed on elasticsearch is possible, but the implementation will require building an in memory representation of it, which will cost more.

On Friday, June 3, 2011 at 3:22 AM, Andre wrote:

> Ah, ok thanks.
> 
> What about a scripting feature in the input JSON? Do you think this  
> makes sense?
> 
> On Jun 3, 8:49 am, Shay Banon \<[shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) ([http://elasticsearch.com](http://elasticsearch.com))\> wrote:
> 
> > He ment that you will pass the date itself, preferable as an ISO format. Its not too difficult to add a timestamp field, as long as clocks are in sync. I think there is already an issue for that.
> > 
> > On Friday, June 3, 2011 at 1:48 AM, Andre wrote:
> > 
> > > Thanks, all my servers a synced to a time server. How easy is it to  
> > > add a special field like like \_timestamp?
> > 
> > > On Jun 2, 5:44 pm, Shay Banon \<[shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) ([http://elasticsearch.com](http://elasticsearch.com))\> wrote:
> > > 
> > > > You will need to add the timestamp yourself. We can add a special field, something like \_timestamp that gets automatically added by elasticsearch, the problem with that is the fact that you will need to make sure the different machines in the cluster are sync'ed time wise.
> > 
> > > > On Thursday, June 2, 2011 at 10:19 AM, Weiwei Wang wrote:
> > > > 
> > > > > try  
> > > > > curl -XPOST '[http://localhost:9200/index/type'-d'](http://localhost:9200/index/type'-d'){"create":'$  
> > > > > (date)'}'
> > 
> > > > > On Jun 2, 1:59 pm, Andre \<[andre.ba...@gmail.com](mailto:andre.ba...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > > 
> > > > > > Hi guys,
> > 
> > > > > > I would like to add a creation date to every JSON document that I add  
> > > > > > to the index.  
> > > > > > How would I do that?
> > 
> > > > > > Thanks,
> > 
> > > > > > Andre

---

<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, 4:04am UTC](https://discuss.elastic.co/t/timestamp/4529/9 "2017-07-06T04:04:46Z")

</div>


