Remove Empty Bucket from Sub Aggregation

We are using multi level Aggregation:
`{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": []
}
}
},

"aggs": {
	"FIELD1": {
		"terms": {
			"field": "City"
		},
		"aggs": {
			"FIELD2": {
				"terms": {
					"field": "Class"
				}
			}
		}
	}
}

}`

We have buckets of "City" and each bucket of City has buckets of "Class". Now for some, Class Bucket is empty as the value of the field is NULL. How can we remove Empty Bucket from the Aggregation.

i made script below.

{
  "size": 0,
  "aggregations": {
    "in_product": {
      "filter": {
        "exists": {
          "field": "Class"
        }
      },
      "aggs": {
        "FIELD1": {
          "terms": {
            "field": "City"
          },
          "aggs": {
            "FIELD2": {
              "terms": {
                "field": "Class"
              }
            }
          }
        }
      }
    }
  }
}

Thanks this worked :slightly_smiling:

Another question would be how can we get back the documents even if the Class field is null. Currently we are getting empty buckets when Class is Null for some keys in City.