Skip to content

Instantly share code, notes, and snippets.

@we4tech
Created April 9, 2014 09:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save we4tech/10244374 to your computer and use it in GitHub Desktop.
Save we4tech/10244374 to your computer and use it in GitHub Desktop.
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