title: How to get specific _source fields in aggregation
body: <p>I am exploring ElasticSearch, to be used in an application, which will handle large volumes of data and generate some statistical results over them. My requirement is to retrieve certain statistics for a particular field. For example, for a given field, I would like to retrieve its unique values and document frequency of each value, along-with the length of the value. The value lengths are indexed along-with each document.
  So far, I have experimented with <code>Terms Aggregation</code>, with the following query:</p>
  
  <pre><code>{
    "size": 0,
    "query": {
    "match_all": {}
  },
   "aggs": {
   "type_count": {
     "terms": {
       "field": "val.keyword",
       "size": 100
     }
    }
   }
  }
  </code></pre>
  
  <p>The query returns all the values in the field <code>val</code> with the number of documents in which each value occurs. I would like the field <code>val_len</code> to be returned as well. Is it possible to achieve this using ElasticSearch? In other words, is it possible to include specific <code>_source</code> fields in buckets? I have looked through the documentation available online, but I haven't found a solution yet. 
  Hoping somebody could point me in the right direction. Thanks in advance!</p>
  
  <p>I tried to include <code>_source</code> in the following manners:</p>
  
  <pre><code> "aggs": {
      "type_count": {
       "terms": {
          "field": "val.keyword",
          "size": 100        
        },
          "_source":["val_len"]
      }
    }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>"aggs": {
   "type_count": {
     "terms": {
       "field": "val.keyword",
       "size": 100,
        "_source":["val_len"]
      }     
    }
  }
  </code></pre>
  
  <p>But I guess this isn't the right way, because both gave me parsing errors.</p>