How to apply a date format to results from a query for date fields


(pulkitsinghal) #1

Lets say that a date is stored in a format such that the result comes back
in JSON as:
{
startDate: 959904000000
}

Is there any way to specify a transformation to a date format like YEAR in
the query itself?
Sp that the result coming back which may be stored on ES as 959904000000
... will be shown in the returned JSON as the year 2005?


(Shay Banon) #2

You mean you index it as startDate: 959904000000? You could install use a
script field to get hte value and munge it how you like
http://www.elasticsearch.org/guide/reference/api/search/script-fields.html.

On Sun, Apr 15, 2012 at 5:26 AM, pulkitsinghal pulkitsinghal@gmail.comwrote:

Lets say that a date is stored in a format such that the result comes back
in JSON as:
{
startDate: 959904000000
}

Is there any way to specify a transformation to a date format like YEAR in
the query itself?
Sp that the result coming back which may be stored on ES as 959904000000
... will be shown in the returned JSON as the year 2005?


(system) #3