Closed
Description
Currently the date_histogram accepts an extended_bounds
argument, but it would be great if it offered a bounds
argument.
bounds
and extended_bounds
would be mutually exclusive, but operate similarly with two main differences:
bounds
would effectively act like a filter and ignore any documents that did not fit into the specified time window- the
bounds
argument would continue to be an object withmin
andmax
properties, but could optionally have atarget_buckets
property. Specifying thetarget_buckets
would automatically calculate an intervalinterval
that cleanly dividing the specified bounds into about as many buckets as requested.
Here is an example request that would ideally return 52 weekly buckets. Note that a "clean" interval (1w
) is chosen over an interval that would have provided exactly 50 buckets.
{
"x-axis": {
"date_histogram": {
"field": "@timestamp",
"bounds": {
"min": 1388534400000, // 2014-01-01T00:00:00.000Z
"max": 1420070399999, // 2014-12-31T23:59:59.999Z
"target_buckets": 50
}
}
}
}