Created
July 24, 2015 14:57
-
-
Save jpountz/cebb8452648c36099cee to your computer and use it in GitHub Desktop.
This file contains 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
DELETE test | |
PUT test | |
{ | |
"mappings": { | |
"test": { | |
"properties": { | |
"start": { | |
"type": "date" | |
}, | |
"duration": { | |
"type": "long" | |
} | |
} | |
} | |
} | |
} | |
PUT test/test/1 | |
{ | |
"start": "2015-07-12T09:14:01Z", | |
"duration": 10000 | |
} | |
PUT test/test/2 | |
{ | |
"start": "2015-07-12T10:20:50Z", | |
"duration": 20000 | |
} | |
PUT test/test/3 | |
{ | |
"start": "2015-07-12T12:00:42Z", | |
"duration": 5000 | |
} | |
GET test/_search | |
{ | |
"aggs": { | |
"my_histo": { | |
"date_histogram": { | |
"script": "start = doc['start'].value; duration = doc['duration'].value * 1000; l = []; for (long i = 0; i < duration; i += interval) { l.add(start + i); }; return l;", | |
"params": { | |
"interval": 3600 | |
}, | |
"interval": "hour" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a question about your script. You return "l" to elasticsearch. How does elasticsearch use that value?