Is it possible to have milliseconds since 1970/01/01 indexed as 'date' type?


(Jae Lee) #1

Hi,

I have a timestamp field that I want to index as 'date' type. It holds
milliseconds since 1970/01/01.

Is it possible to get ES to index it as 'date'?

J


(Administrator-2) #2
Why not store two fields?

On your end, you can easily turn those milliseconds since 1970/01/01

into a date/time value to store, and you can also store the number of
milliseconds in a numeric field.

This way, you can index on both and perform the appropriate search

when needed for a small computational cost when inserting/updating.

	- Nick

-----Original Message-----
From: jlee [mailto:jlee119@gmail.com]
Sent: Thursday, March 03, 2011 11:34 AM
To: users
Subject: Is it possible to have milliseconds since 1970/01/01 indexed as
'date' type?

Hi,

I have a timestamp field that I want to index as 'date' type. It holds
milliseconds since 1970/01/01.

Is it possible to get ES to index it as 'date'?

J


(Shay Banon) #3

The date type already stores internally the date as UTC milliseconds since epoch. There is no option to provide the milliseconds directly, I guess the more interesting question here, if it was allowed, is how to handle time zone when providing just milliseconds. The date field mapper can get the milliseconds and make sure its in UTC, but that will be based on the local machine it is running on, and not (possibly) the client machine.

It might just be simpler to convert it to an ISO date format, and push that into elasticsearch.
On Thursday, March 3, 2011 at 7:53 PM, Administrator wrote:

Why not store two fields?

On your end, you can easily turn those milliseconds since 1970/01/01
into a date/time value to store, and you can also store the number of
milliseconds in a numeric field.

This way, you can index on both and perform the appropriate search
when needed for a small computational cost when inserting/updating.

  • Nick

-----Original Message-----
From: jlee [mailto:jlee119@gmail.com]
Sent: Thursday, March 03, 2011 11:34 AM
To: users
Subject: Is it possible to have milliseconds since 1970/01/01 indexed as
'date' type?

Hi,

I have a timestamp field that I want to index as 'date' type. It holds
milliseconds since 1970/01/01.

Is it possible to get ES to index it as 'date'?

J


(system) #4