title: Count distinct id where field exists
body: <p>I am trying to create in ElasticSearch a query that will lists distinct <code>user_label.id</code> each with the respectiv counts:</p>
  
  <p>Sample document looks likes this:</p>
  
  <pre><code>{
      "_index": "labels",
      "_type": "users",
      "_id": "484",
      "_version": 69,
      "found": true,
      "_source": {
          "id": 484,
          "is_complete": 1,
          "language": "nl",
          "user_label": [
              {
                  "guid": {
                      "163579": {
                          "order_id": 163579
                      }
                  },
                  "id": "boleto"
              }
          ]
      }
  }
  </code></pre>
  
  <p>Mapping is type <code>nested</code>. </p>
  
  <pre><code>"user_label" : {
    "type" : "nested",
    "properties" : {
       "guid" : {},
       "id" : {
          "type" : "string"
       },
       "tag" : {
          "type" : "string"
       }
   }
  }
  </code></pre>
  
  <p>I want to build a table like:</p>
  
  <pre><code>+---------------+-------+
  | boleto        | 32453 |
  | paid          | 34345 |
  | reminder_sent |   345 |
  +---------------+-------+
  </code></pre>
  
  <p>I have so far this for language, but need help creating for <code>user_label.id</code>:</p>
  
  <pre><code>{
      "size": 0,
      "aggs": {
          "genders": {
              "terms": {
                  "field": "language"
              }
          }
      }
  }
  </code></pre>
  
  <p>Have tried using <code>"field":"user_label.id"</code> but it didn't worked. I tried this with type <code>properties</code> and for there the dot notation works, but doesn't seam to work with type <code>nested</code></p>