Timestamp


(Andre) #1

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


Add date to each new created entry in Elasticsearch
(Weiwei Wang) #2

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

On Jun 2, 1:59 pm, Andre 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


(Shay Banon) #3

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 '{"create":'$
(date)'}'

On Jun 2, 1:59 pm, Andre <andre.ba...@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


(Andre) #4

Weiwei's example,

C:\elasticsearch-0.16.2\bin>curl -XPOST 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 wrote:

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

On Jun 2, 1:59 pm, Andre 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


(Andre) #5

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 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 '{"create":'$
(date)'}'

On Jun 2, 1:59 pm, Andre <andre.ba...@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


(Shay Banon) #6

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 (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 '{"create":'$
(date)'}'

On Jun 2, 1:59 pm, Andre <andre.ba...@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


(Andre) #7

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 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 (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'{"create":'$
(date)'}'

On Jun 2, 1:59 pm, Andre <andre.ba...@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


(Shay Banon) #8

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 (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 (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'{"create":'$
(date)'}'

On Jun 2, 1:59 pm, Andre <andre.ba...@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


(system) #9