How to get current date in script

Hi,

I want to write a script to calculate the number of days from current date
on a date field. I can use a script like:
"script_fields": {
"test": {
"script": "doc['date'].date.year * doc['date'].date.dayOfYear - "
}
}

How to get the current date? No date related function is mentioned in the
help(
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html
).

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/81d6726b-88ca-4a62-829d-0a7b970b8669%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Abhishek ,

Something similar to this should work -

{
"script_fields": {
"test": {
"script": "doc['date'].value - new Date().getTime() * 1000"
}
}
}

Thanks
Vineeth

On Mon, Sep 15, 2014 at 9:41 PM, Abhishek Gupta abhi.bansal21@gmail.com
wrote:

Hi,

I want to write a script to calculate the number of days from current date
on a date field. I can use a script like:
"script_fields": {
"test": {
"script": "doc['date'].date.year * doc['date'].date.dayOfYear - "
}
}

How to get the current date? No date related function is mentioned in the
help(
Elasticsearch Platform — Find real-time answers at scale | Elastic
).

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/81d6726b-88ca-4a62-829d-0a7b970b8669%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/81d6726b-88ca-4a62-829d-0a7b970b8669%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nzE6oDppCzf67ED3d%2Bhgq995wPDTi7f7rOPSBsyE578Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.