title: C# Nest & Elasticsearch 6.x : How to filter/count nested fields (in inner List<object>)
body: <p>Here is my mapping</p>
  
  <pre><code>[ElasticsearchType(Name = "Topic")]
  public class Topic
  {
      [Number(NumberType.Integer, Coerce = true)]
      public EnumStatus Status { get; set; }
  
      [Nested]
      public List&lt;KeywordValue&gt; KeywordValues { get; set; }
  
  }
  
  [ElasticsearchType(Name = "KeywordValue")]
  public class KeywordValue
  {
      [Keyword]
      public string KeywordId { get; set; }
  
  }
  </code></pre>
  
  <p>I have 10 documents of type <code>Topic</code> in the index, each <code>KeywordValues</code> property/field of the type <code>List&lt;KeywordValue&gt;</code> contains 5 <code>KeywordValue</code> (5 elements in the list).</p>
  
  <p>9 documents have status "<code>Enabled</code>";</p>
  
  <p>I'm trying to count the total number of elements in each nested <code>KeywordValues</code> field. The result returned is 9 but I would like to get 45 (9*5)</p>
  
  <p>I'm doing this: </p>
  
  <pre><code>var response = Topic.CurrentConnection.Search&lt;Topic&gt;(s =&gt; s
                  .Size(0)
                  .Aggregations(fa =&gt; fa
                      .Filter("filtered_aggs", f =&gt; f
                          .Filter(fd =&gt; fd.Term(t =&gt; t.Status, Topic.EnumStatus.Enabled))
                          .Aggregations(ta =&gt; ta
                                  .Nested("kv", n=&gt;n.Path(p =&gt; p.KeywordValues)
                                      .Aggregations(aa =&gt; aa
                                          .ValueCount("vc", v =&gt; v.Field(vf =&gt; vf.KeywordValues.First().KeywordId))))
                              )
                          )
                      )
              );
  
  
          if (response.IsValid)
          {
              var agg = response.Aggregations.Nested("filtered_aggs");
              var n = agg.Nested("kv");
              var z = n.ValueCount("vc");
              result.Object = z.Value;
          }
  </code></pre>
  
  <p>Raw query equivalent:           </p>
  
  <pre><code># Request:
  {
    "size": 0,
    "aggs": {
      "filtered_aggs": {
        "filter": {
          "term": {
            "Status": {
              "value": 0
            }
          }
        },
        "aggs": {
          "kv": {
            "nested": {
              "path": "KeywordValues"
            },
            "aggs": {
              "vc": {
                "value_count": {
                  "field": "KeywordValues.KeywordId"
                }
              }
            }
          }
        }
      }
    }
  }
  # Response:
  {
    "took" : 80,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "skipped" : 0,
      "failed" : 0
    },
    "hits" : {
      "total" : 10,
      "max_score" : 0.0,
      "hits" : [ ]
    },
    "aggregations" : {
      "filter#filtered_aggs" : {
        "doc_count" : 9,
        "nested#kv" : {
          "doc_count" : 9,
          "value_count#vc" : {
            "value" : 9
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Any idea? Thanks a lot.</p>