Help with nested aggregation query

I'm trying to pull together a query to get a historical total of objects with a specific status. Our objects look something like this:

"groupName" : "someString",
"quantity" : integer
"history" : [
    "date" : timestamp
    "status" : "status_string"

The history object is a nested object and is an array of the times that the status changed (from AVAILABLE to UNAVAILABLE as a simple example). I'm trying to create a date-histogram type aggregation that allows me to see the sum of quantity of a given groupName that were in a given state at a certain bucket in time. Said another way, looking at the daily total of objects available "as of" a certain date, meaning that the date associated with their "AVAILABLE" status object was prior to the end date of the bucket.

I've really been struggling with how to go about starting to generate this aggregation and any assistance in how to approach it would be appreciated.

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