How to add date range to query?

Hi,

How can I add a range filter to the usage_offset part of this query? I want usage_current to return the last known value andusage_offset the return the last known value for 1 hour or more ago.

I tried adding range filters and range aggegrations but they all cause the query to fail.

{
  "query": {
    "match": {
      "name": "test"
    }
  },
           "aggs": {
                "usage_current": {
                    "top_hits": {
                        "sort": [
                            {
                                "@timestamp": {
                                    "order": "desc"
                                }
                            }
                        ],
                        "size" : 1
                    }
                },
                "usage_offset": {
                    "top_hits": {
                        "sort": [
                            {
                                "@timestamp": {
                                    "order": "desc"
                                }
                            }
                        ],
                        "size" : 1
                    }
                }
            }
}

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