-
-
Save rybesh/3e83cc883a6a82e79f34 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