0

I want to get metric (count, min, max, avg, sum) called TimeToExecute by week/month after filtering the documents in the index, this query throws this error

"reason" : "Found two aggregation type definitions in [agg1]: [filter] and [data]",

GET _search
{
  "size": 0,
  "aggs": {
    "agg1": {
      "filter": { 
        "bool": {
          "must": [
            {
              "term": { "api.name": "SomeName" }
            },
            { 
              "term": { "api.category": "SomeCategory" }
            },
            {
              "range": {
                "@timestamp": {
                  "gte": "now-365d/d",
                  "lte": "now/d"
                }
              }
            }
          ]
        }
      },
      "data" : {
        "date_histogram": {
          "field": "@timestamp",
          "calendar_interval": "month"
        },
        "aggs": {
          "TimeToExecute": {
            "stats": {
              "field": "api.duration"
            }
          }
        }
      }
    }
  }
}

Can you help with how to format this query?

I am trying to follow the help page, but I don't see any example of filtering before applying the agg - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-rate-aggregation.html

user9969157
  • 75
  • 4
  • 14

0 Answers0