Aggregation error: Could not find aggregator type in [aggs]

I am having some trouble with multiple aggregations in elasticsearch. I am trying to first find all documents whose value for "field_0" is "a_string" and then aggregate twice on those docs based on the fields "field_1" and "field_2". This is the code I used:

GET logstash-*/_search?size=0
{
  "query": {
    "match_phrase": {
      "field_0": "a_string"
    }
  },
  "aggs": {
    "name_0": {
      "terms": {
        "field": "field_1"
      }
    },
    "aggs": {
      "name_1": {
        "terms": {
          "field": "field_2"
        }
      }
    }
  }
}

When I ran the code this was the error message:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "Could not find aggregator type [name_1] in [aggs]",
        "line": 14,
        "col": 17
      }
    ],
    "type": "parsing_exception",
    "reason": "Could not find aggregator type [name_1] in [aggs]",
    "line": 14,
    "col": 17
  },
  "status": 400
}

I have basically no clue why this error appears - when I run the aggregation with just "field_1" it works just fine. Any help with resolving this error is greatly appreciated.

Nevermind, I found the reason - my second aggregation should be parallel to terms and under name_0, the issue is now resolved.

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