Unknown key for a START_OBJECT in [3]

Hi all,
im getting this error on aggs query and i want to do multiple aggregation can you pls help here.

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Unknown key for a START_OBJECT in [3].",
        "line" : 35,
        "col" : 8
      }
    ],
    "type" : "parsing_exception",
    "reason" : "Unknown key for a START_OBJECT in [3].",
    "line" : 35,
    "col" : 8
  },
  "status" : 400
}

When making this query on elasticsearch. pls help me correct the query i want do more multiple aggregation query on index.

GET /_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "@timestamp": {
              "gte": 1663666935141,
              "lte": 1663668735142,
              "format": "epoch_millis"
            }
          }
        },
        {
          "query_string": {
            "analyze_wildcard": true,
            "query": "service.name:*kmw*"
          }
        }
      ]
    }
  },
  "aggs": {
    "2": {
      "terms": {
        "field": "labels.client_id",
        "size": 10000,
        "order": {
          "_key": "desc"
        },
        "min_doc_count": 1
      }
    }
  },
  "3": {
      "sum": {
        "field": "labels.row_count",
        "size": 10000,
        "order": {
          "_key": "desc"
        },
        "min_doc_count": 1
      }
    }
}

Would someone guide me correcting this error, im not able to do multiple aggregation query on index.
Thanks.

The key "3" and its value should be inside of the "aggs" field, e.g. something like:

{
...
  "aggs": {
    "2": { ... },
    "3": { ... }
  }
...
}

When i do that i get.. Duplicate key "aggs" syntax errror so the query wont run

@yang_wang thanks for your time and help. the issue is resolved. thank you

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