title: Grouping in Elastic Search
body: <p>I have a problem with doing grouping operation in elastcicSearch.</p>
  
  <p>Actually, I have 3 fields in my document. that is as under:</p>
  
  <pre><code>Id Type  Year
  </code></pre>
  
  <p>Now I want to do grouping on ExceptionType and Year and count it in "ResultCount".</p>
  
  <p>I tried this one but it is not working:</p>
  
  <pre><code>.Aggregations(a =&gt; a
              .ValueCount("ResultCount", c =&gt; c
                  .Field(p =&gt; p.Id)
                  .Field(p=&gt; p.Year)
              ))
               .Aggregations(a =&gt; a
                  .Terms("Type", st =&gt; st
                      .Field(o =&gt; o.Type)
                      .Size(10))).Size(5)
               .Aggregations(aa =&gt; aa
                      .Max("Year", m =&gt;  m
                          .Field(o =&gt; o.Year)
                      ))
             );
  </code></pre>
  
  <p>Please give a solution for this problem as soon as possible. thank you.</p>