I'm trying to combine a date_histogram agg with a stats agg to find the 
min/max within a bucket of documents, so far so good, but now I need a 
field from the document where the Min/Max was actually found.

My index basically has millions of x,y datapoints that I want to search for 
and plot.

What I want are the 2 documents from each bucket where the 'y' value was a 
min and a max.  

This query successfully gave me buckets divided by 300s intervals and the 
min/max y values within those buckets. Problem is, I have no way of linking 
those min/max values to their corresponding 'x' value for plotting. 

{
    "size": 0,
    "aggs" : {
        "vals" : {
            "filter" : { "term" : { "component" : "data_to_plot" } },
 "aggs" : {
                "values_over_time" : {
                    "date_histogram" : {
                        "field" : "x",
                        "interval" : "300s"
                    },
                    "aggs": {
                      "stats_y": {"stats": {"field": "y"} },               
       
                    }
                }
            }
        }
    }          
}

Any suggestions?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/bfa7f7d9-6d8c-493d-bcea-5acae891ab07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to