Is it possible to do a date histogram aggregation and get percent totals?

I have an Elasticsearch query that creates aggregations based on specific search terms. Within each bucket of the date histogram aggregation, the doc_count gives the total number of documents matching the search criteria.

What I would also like is the total number of background documents for that time period so that I can do a ratio comparison. For instance, if my search term is "president" and the doc_count in one of the buckets is 45,000, I'd like to get back the total number of documents for that time period as well.

I know this could be achieved by doing two separate aggregations, but I was curious if there was any built-in functionality to get the bg_count for date histogram aggregations (all documents in that time range, not just matching documents).

Thank you!

a second aggregation using the global agg sounds like the way to go here for me.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.