Last active
November 13, 2015 10:33
-
-
Save edwardsmit/0a0a3f12f87e5f6eb3a7 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
curl -XDELETE 'localhost:9200/timeaggregate'; echo | |
curl -XPUT 'localhost:9200/timeaggregate'; echo | |
curl -XPUT 'localhost:9200/timeaggregate/event/_mapping' -d '{ | |
"event": { | |
"properties": { | |
"timestamp": { | |
"type": "date" | |
} | |
} | |
} | |
}'; echo | |
curl -XPUT 'localhost:9200/timeaggregate/event/10' -d '{ | |
"timestamp": "2015-11-03T14:21:00Z" | |
}'; echo | |
curl -XPUT 'localhost:9200/timeaggregate/event/11' -d '{ | |
"timestamp": "2015-11-03T14:25:59" | |
}'; echo | |
curl -XPUT 'localhost:9200/timeaggregate/event/12' -d '{ | |
"timestamp": "2015-11-03T14:44:00Z" | |
}'; echo | |
curl -XPUT 'localhost:9200/timeaggregate/event/13' -d '{ | |
"timestamp": "2015-11-03T14:48:59" | |
}'; echo | |
curl -XPUT 'localhost:9200/timeaggregate/event/14' -d '{ | |
"timestamp": "2015-11-03T14:50:00Z" | |
}'; echo | |
curl -XPOST 'http://localhost:9200/timeaggregate/_refresh'; echo | |
### For reference: Without the extended_bounds | |
curl -XGET "http://localhost:9200/timeaggregate/event/_search?size=0&pretty" -d' | |
{ | |
"query": {"match_all": {}}, | |
"aggs": { | |
"timeslots": { | |
"date_histogram": { | |
"field": "timestamp", | |
"interval": "5m" | |
}, | |
"aggs": { | |
"timestats": { | |
"stats": {} | |
} | |
} | |
} | |
} | |
}'; echo | |
### Failing Query | |
### I would like to have the time-buckets start at the min-value found in the bucket, not on a boundary dictated | |
### by the interval. | |
### Referring to the extended_bounds.min yields a parse-error stating that the dateime value can't be parsed. | |
curl -XGET "http://localhost:9200/timeaggregate/event/_search?size=0&pretty" -d' | |
{ | |
"query": {"match_all": {}}, | |
"aggs": { | |
"timeslots": { | |
"date_histogram": { | |
"field": "timestamp", | |
"interval": "5m", | |
"extended_bounds": { | |
"min": "timestats.min" | |
} | |
}, | |
"aggs": { | |
"timestats": { | |
"stats": {} | |
} | |
} | |
} | |
} | |
}'; echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment