title: ElasticSearch: Querying a field that's an array of objects
body: <p>I've got data indexed using ElasticSearch, and I'm having trouble querying a particular field. A snippet of the JSON is as follows:</p>
  
  <pre><code> {
   "_index": "indexName",
   "_type": "type",
   "_id": "00001",
   "color": "red",
   "place": "london",
   "person": [
        {
             "name": "john",
             "friends": [
                 "mary",
                 "jane"
             ]
        }
        {
             "name": "jack",
             "friends": [
                 "lisa",
                 "alex"
             ]
        }
  
   ]
   }
  </code></pre>
  
  <p>I need to query the index and pick out all records where one of the <code>name</code>s inside <code>person</code> is "john".</p>
  
  <p>I'm using <code>Client.Search</code> to do this, and I've had no trouble querying the fields that aren't nested (like <code>color</code>) by using:</p>
  
  <pre><code> var searchResults = client.Search&lt;People&gt;(s =&gt; s
              .Index("indexName")
              .Type("type")
              .Query(q =&gt; q
                  .Bool(b =&gt; b
                      .Must(
                          x =&gt; x.Match(m =&gt; m.OnField(p =&gt; p.color).Query("red")),
                          x =&gt; x.Match(m =&gt; m.OnField(p =&gt; p.place).Query("london"))))));
  </code></pre>
  
  <p>I've got <code>People</code> defined as follows:</p>
  
  <pre><code>public class People
  {
      public string color {get; set; }
      public string place {get; set; }
      public List&lt;Person&gt; person {get; set; }
  }
  public class Person
  {
      public string name {get; set; }
      // "friends" isn't here as I don't pull data from it
  }
  </code></pre>
  
  <p>I'm unsure as to how to query on <code>name</code> as it's "inside" <code>people</code> - any help is greatly appreciated.</p>