Do you want Days in Integer or Float?
Field Type Double
long datenow = new Date().getTime();
long datewas = doc['@timestamp'].value.getMillis();
double days = (datenow - datewas) / 86400000.0;
emit (days);
Field Type Long
long datenow = new Date().getTime();
long datewas = doc['@timestamp'].value.getMillis();
long days = (datenow - datewas) / 86400000;
emit (days);