title: How can I iterate elastic search Bucket using c#
body: <p>Currently, I am using NEST API to get data from elastic search and I am trying Term Aggregation and the response was valid but I was unable to access the data in the bucket.
  Basically, unable to iterate through the fields in the bucket.</p>
  
  <p>Here is my code to do the term aggregation</p>
  
  <pre><code>       var result = client.Search&lt;GoodDataAttribute&gt;(s =&gt; s 
                  .Aggregations(a =&gt; a 
                  .Terms("Resourcegroup", st =&gt; st 
                  .Field(o =&gt; o.ResourceGroup) 
                  .Size(16) 
                  .ExecutionHint(TermsAggregationExecutionHint.Map) 
                  ))); 
              var result1 = result.Documents; 
              Console.WriteLine(result1); 
              foreach (var result2 in result.Documents) 
              { 
                  Console.WriteLine(result2.ResourceGroup); 
              } 
              var resultGroups = result.Aggregations; 
              Console.WriteLine(resultGroups.Count); 
              foreach (var resultGroup in resultGroups.Values) 
              { 
                  Console.WriteLine(resultGroup.ToString()); 
              } 
  </code></pre>