In Sense (you did not specify the ES version, this works against 2.3.2):
GET your_index/_search
{
"size": 1,
"script_fields": {
"now": {
"script": "new Date().getTime()"
}
}
}
In the Java API, this will be something like (not verified):
yourSearchRequestBuilder.addScriptField("now", "new Date().getTime()");
, your_index 1 , - script; .