title: Select aggregations based on sub aggregation results doc count
body: <p>I am aiming to only select those aggregations that have min_doc_count match defined  in sub aggregations. Not sure if it is possible. 
  Basically I want to select only those buckets that have propertyid belonging to a particular import.
  Here is my query.</p>
  
  <pre><code>GET properties/_search
  {
    "size": 0,
    "query": {
      "terms": {
        "Agency_Id": [
          "16"
        ]
      }
    },
    "aggregations": {
      "property_id": {
        "terms": {
          "field": "PropertyId",
          "min_doc_count": 2,
          "size": 10000
        },
        "aggregations": {
          "import_filter": {
            "filter": {
              "term": {
                "Import_Id": "90040"
              }
            },
            "aggregations": {
              "import_id": {
                "terms": {
                  "field": "Import_Id",
                  "min_doc_count": 1,
                  "size": 10000
                }
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Actual result</p>
  
  <pre><code>{
    "took" : 16,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "skipped" : 0,
      "failed" : 0
    },
    "hits" : {
      "total" : 1163,
      "max_score" : 0.0,
      "hits" : [ ]
    },
    "aggregations" : {
      "property_id" : {
        "doc_count_error_upper_bound" : 0,
        "sum_other_doc_count" : 0,
        "buckets" : [
          {
            "key" : "011162330",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 1,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [
                  {
                    "key" : 90040,
                    "doc_count" : 1
                  }
                ]
              }
            }
          },
          {
            "key" : "6065590",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 1,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [
                  {
                    "key" : 90040,
                    "doc_count" : 1
                  }
                ]
              }
            }
          },
          {
            "key" : "6289352",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 1,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [
                  {
                    "key" : 90040,
                    "doc_count" : 1
                  }
                ]
              }
            }
          },
          {
            "key" : "gd-00-022386",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 0,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [ ]
              }
            }
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>Expected</p>
  
  <pre><code>{
    "took" : 16,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "skipped" : 0,
      "failed" : 0
    },
    "hits" : {
      "total" : 1163,
      "max_score" : 0.0,
      "hits" : [ ]
    },
    "aggregations" : {
      "property_id" : {
        "doc_count_error_upper_bound" : 0,
        "sum_other_doc_count" : 0,
        "buckets" : [
          {
            "key" : "011162330",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 1,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [
                  {
                    "key" : 90040,
                    "doc_count" : 1
                  }
                ]
              }
            }
          },
          {
            "key" : "6065590",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 1,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [
                  {
                    "key" : 90040,
                    "doc_count" : 1
                  }
                ]
              }
            }
          },
          {
            "key" : "6289352",
            "doc_count" : 2,
            "import_filter" : {
              "doc_count" : 1,
              "import_id" : {
                "doc_count_error_upper_bound" : 0,
                "sum_other_doc_count" : 0,
                "buckets" : [
                  {
                    "key" : 90040,
                    "doc_count" : 1
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
  </code></pre>