Date, Scripted Fields

Hello All,

I'm getting data as below from my application

....."extraParams":[{"name":"Item","value":"item1"},{"name":"DateTime","value":"0001519156380000"},....

I would like the data of the field value as Date instead of a string when the name data is 'DateTime'. I tried using the scripted field for this, but not working..

if doc['extraParams.name'].value == 'name' then
retrun new Date(Long.parseLong(doc['extraParams.value'].value)

Any help or guidance would be appreciated.

I have made few changes to mapping '"store": true', and recreated the index. Now, the script works without an error, but not seeing value as expected.

I verified the source documents, and I see a field with date.

if (doc['extraParams.name.keyword'].value == "DateTime") {
return new Date(Long.parseLong(doc["extraParams.value.keyword"].value));
}

What does it display with the current scripted field? the number 0001519156380000 as a string?

yeah, string.

I got it working. Thanks for responding.