Performing range summary on the result of a metric within a bucket


(Michael Sick) #1

I have what will be a long running time series table that I would like to
aggregate by time buckets and analyze:

  1. Query & Filter (in this case by dates & a term query on user_guid)
    (Working)
  2. Bucket by time for analysis (working using the aggs "date_aggregate"
    and "heartRate_stats" aggs
  3. Perform range counts on the metrics produced by the metrics within
    the buckets. *Not working. *The "heartRate_zoneCounts1" aggregator gets
    zero counts - seems you can't point from the top down. The
    "heartRate_zoneCounts" aggregator does counts of the individual documents
    within the bucket (nice - but not what I'm looking for).

So how would I apply a range aggregate to the outcome of the
heartRate_stats metric and get only one value per date_aggregate bucket? I
can post process the results to apply a range but would rather have ES do
it for me. Any / all help apprecuated. Thanks in advance!
--Mike

The Results
mikeasick https://gist.github.com/mikeasick /
gist:8734325https://gist.github.com/mikeasick/8734325

The Data (per second stream of the information below)
mikeasick https://gist.github.com/mikeasick / gist:8734404
https://gist.github.com/mikeasick/8734404

The Search

curl -XGET "http://localhost:9200/vitals/vital/_search?pretty=true" -d'
{

"size": 0,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {

    "and": {
      "filters": [
        {
          "term": {"user_guid": "0ad08904-c1cf-46cf-9a04-e0865c1cced2"}
        },
        {
          "numeric_range": {

            "recorded_time": {
              "gte": "2013-01-05T04:44:33.396-05:00",
              "lte": "2014-01-05T04:44:33.396-05:00"
            }
          }
        }

      ]
    }
  }
}

},
"aggs": {
"date_aggregate": {
"date_histogram": {
"field": "recorded_time",
"interval": "5m"

  },
  "aggs": {
    "heartRate_zoneAverageCounts": {

       "range" : {
            "field" : "heartRate_stats.avg",
            "ranges" : [
                { "to" : 50 },
                { "from" : 50, "to" : 100 },

                { "from" : 100 }
            ]
        }

    },
    "heartRate_zoneCounts": {
       "range" : {

            "field" : "heartRate",
            "ranges" : [
                { "to" : 50 },
                { "from" : 50, "to" : 100 },
                { "from" : 100 }

            ]
        }
    },
    "heartRate_stats": {
      "extended_stats": {
        "field": "heartRate"

      }
    }
  }
}

}
}'

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAP8axnB_ysa7DMMnsxou%2BJoaPe7kzT3CooLrn_oYi1petadF8A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Michael Sick) #2

Forgot to post the mapping (here mikeasickhttps://gist.github.com/mikeasick /
gist:8738689 https://gist.github.com/mikeasick/8738689) and that it's
using 1.0.0.Beta2 and Java 1.7.0_25 on Windows 7.

Thanks!

On Fri, Jan 31, 2014 at 10:42 AM, Michael Sick <
michael.sick@serenesoftware.com> wrote:

I have what will be a long running time series table that I would like to
aggregate by time buckets and analyze:

  1. Query & Filter (in this case by dates & a term query on user_guid)
    (Working)
  2. Bucket by time for analysis (working using the aggs
    "date_aggregate" and "heartRate_stats" aggs
  3. Perform range counts on the metrics produced by the metrics within
    the buckets. *Not working. *The "heartRate_zoneCounts1" aggregator
    gets zero counts - seems you can't point from the top down. The
    "heartRate_zoneCounts" aggregator does counts of the individual documents
    within the bucket (nice - but not what I'm looking for).

So how would I apply a range aggregate to the outcome of the
heartRate_stats metric and get only one value per date_aggregate bucket? I
can post process the results to apply a range but would rather have ES do
it for me. Any / all help apprecuated. Thanks in advance!
--Mike

The Results
mikeasick https://gist.github.com/mikeasick / gist:8734325https://gist.github.com/mikeasick/8734325

The Data (per second stream of the information below)
mikeasick https://gist.github.com/mikeasick / gist:8734404
https://gist.github.com/mikeasick/8734404

The Search
https://gist.github.com/mikeasick/8734117

curl -XGET "http://localhost:9200/vitals/vital/_search?pretty=true" -d'
{

"size": 0,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {

    "and": {
      "filters": [
        {
          "term": {"user_guid": "0ad08904-c1cf-46cf-9a04-e0865c1cced2"}
        },
        {
          "numeric_range": {

            "recorded_time": {
              "gte": "2013-01-05T04:44:33.396-05:00",
              "lte": "2014-01-05T04:44:33.396-05:00"

            }
          }
        }

      ]
    }
  }
}

},
"aggs": {
"date_aggregate": {
"date_histogram": {
"field": "recorded_time",
"interval": "5m"

  },
  "aggs": {
    "heartRate_zoneAverageCounts": {

       "range" : {
            "field" : "heartRate_stats.avg",
            "ranges" : [
                { "to" : 50 },
                { "from" : 50, "to" : 100 },

                { "from" : 100 }
            ]
        }

    },
    "heartRate_zoneCounts": {
       "range" : {

            "field" : "heartRate",
            "ranges" : [
                { "to" : 50 },
                { "from" : 50, "to" : 100 },
                { "from" : 100 }

            ]
        }
    },
    "heartRate_stats": {
      "extended_stats": {
        "field": "heartRate"

      }
    }
  }
}

}
}'

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAP8axnC1gLEhXk02jKUeP2MQSSeFemmGczvbPTa2eERwqMtYkg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3