Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ElasticSearch result transformer example
var data = [],
now = new Date().getTime();
root.hits.hits.forEach(function(hit) {
var d = new Date(),
ts = hit.fields.expired_at_de * 1000;
d.setTime(ts);
var diffInHours = (now - ts) / 1000.0 / 60.0 / 60.0;
data.push(d.toString() + " [expiring in " + diffInHours + " hours]");
});
return data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.