Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance histogram aggregation - specify number of buckets instead of interval #20590

Closed
nreese opened this issue Sep 20, 2016 · 2 comments
Closed

Comments

@nreese
Copy link
Contributor

nreese commented Sep 20, 2016

The current implementation of the histogram aggregation requires an interval field to specify the histogram bucket size. Providing an appropriate interval requires additional knowledge about the data set, usually the min and max. This additional knowledge can be obtained from Elasticsearch but requires additional HTTP traffic and adds unnecessary complexity to client implementations.

I recommend adding a new parameter, buckets, to the histogram aggregation. Elasticsearch would use this value to automatically calculate an appropriate interval that generates the specified number of buckets taking into consideration all provided queries, filters, and aggregation filters.

{
    "aggs" : {
        "prices" : {
            "histogram" : {
                "field" : "price",
                "buckets" : 25
            }
        }
    }
}
@Bargs
Copy link

Bargs commented Sep 21, 2016

This would be a boon for Kibana because it would allow us to easily auto scale the histogram visualization and protect users from accidentally creating too many buckets, crashing their browser in the process.

As @nreese mentioned we could accomplish this by issuing two requests from the client, the first grabbing the min/max values for the given field. But since the aggregation may have a search query and/or filters associated with it we don't know how performant this would be. I imagine it would be more efficient to implement this option inside elasticsearch so the calculations can be done in a single request.

I think there's some precedence for such an option in the terms agg. Essentially we want the size option from the terms agg, but for histograms.

Thanks for considering!

@clintongormley
Copy link
Contributor

Duplicate of #9572

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants