title: How to get Elasticsearch Key/Values in Aggregation Buckets
body: <p>Is it possible to get more than just a key with Elasticsearch aggregation buckets?  For example if I'm getting countries, I can get the keys as follows:</p>
  
  <pre><code>"aggregations": {
    "countries": {
       "buckets": [
          {
             "key": "china",
             "doc_count": 1
          },
          {
             "key": "italy",
             "doc_count": 1
          },
          {
             "key": "japan",
             "doc_count": 1
          },
          {
             "key": "united-kingdom",
             "doc_count": 1
          }
       ]
    }
  </code></pre>
  
  <p>}</p>
  
  <p>But I would also like get some associated data for example the country name not as a slug: (e.g. China, Italy, Japan, United Kingdom).</p>
  
  <p>Now the mapping is like this</p>
  
  <pre><code>PUT tester/listing/_mapping
  {
    "properties": {
  
      "title": {
        "type": "string"
      }, 
  
      "countries": {
        "type": "string",
        "index": "not_analyzed",
        "doc_values": true
      }
  
    }
  }
  </code></pre>
  
  <p>And the records are indexed as follows:</p>
  
  <pre><code>POST tester/listing/1
  {
  
    "title": "First Listing",
    "countries": ["spain", "italy"]
  
  }
  
  POST tester/listing/2
  {
  
    "title": "Second Listing",
    "countries": ["japan", "united-kingdom"]
  
  }
  </code></pre>