Current date on Script Field

I'm trying to generate a script field in Kibana 4 and I need to compute the difference between a date field and the current date:

(current_date - doc['startDate'].value)

I would also like to know if there is a way I could use the date range (from-to) of every kibana query in the script field. ex:

(to_date - doc['startDate'].value)

Any help?


Lucene expressions, which is the default scripting language, does not support date math. For date support, you can switch to Groovy, using dynamic (insecure!) or static scripts.