title: Unknown key for a START_OBJECT in a multiple script aggregations elasticsearch
body: <p>I'm trying to build a query allowing me to make multiple aggregations on a single query. Here's the request I'm sending :</p>
  
  <pre><code> {
      "size": 1,
      "aggs": {
          "firmNames": {
              "terms": {
                  "field": "firm_name",
                  "size": 100000000
              },
              "aggs": {
                  "domains": {
                      "terms": {
                          "field": "domain",
                          "size": 100000000
                      },
                      "aggs": {
                          "logDates": {
                              "terms": {
                                  "field": "log_date",
                                  "size": 10000000
                              },
                              "aggs": {
                                  "traffics": {
                                      "sum": {
                                          "field": "traffic"
                                      }
                                  },
                                  "script_fields": {
                                      "scripted_metric": {
                                          "script": {
                                              "lang": "painless",
                                              "inline": "HashSet set = new HashSet; set.add(doc['file_name']); return set;"
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
      }}
  </code></pre>
  
  <p>However, I'm getting the following error when executing this query :</p>
  
  <pre><code>   {
        "error" : {`enter code here`
          "root_cause" : [
            {
              "type" : "parsing_exception",
              "reason" : "Unknown key for a START_OBJECT in [script_fields]: [script].",
              "line" : 15,
              "col" : 23
            }
          ],
          "type" : "parsing_exception",
          "reason" : "Unknown key for a START_OBJECT in [script_fields]: [script].",
          "line" : 15,
          "col" : 23
        },
        "status" : 400
      }
  </code></pre>
  
  <p>I've been trying to change this query in many forms to make it works but I always end up with this error.</p>