Created
April 9, 2014 09:01
-
-
Save we4tech/10244374 to your computer and use it in GitHub Desktop.
ElasticSearch result transformer example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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