title: Having trouble with Nested-Objects using Nest
body: <p>When I try to index a doc of my defined type, having a list which is supposed to be mapped as a nested-object ("type":"nested"), it's getting mapped as a regular object type.</p>
  
  <p>Take a look at the code:</p>
  
  <p>I've got a simple class like this one:</p>
  
  <pre><code>[ElasticType()]
  public class MyJob
  {
      [ValueFieldAttribute]
      public int jobCode { get; set; }
  
      [ValueFieldAttribute(Type = FieldType.nested)]
      public IList&lt;JobProfessionalFieldInfo&gt; JobProfessionalFields { get; set; }
  }
  </code></pre>
  
  <p>The code for the JobProfessionalFieldInfo class is:</p>
  
  <pre><code>[ElasticType()]
  public class JobProfessionalFieldInfo
  {
      [ValueFieldAttribute]
      public int JobId { get; set; }
  
      [ValueFieldAttribute]
      public int CategoryId { get; set; }
  }
  </code></pre>
  
  <p>The code for the ValueFieldAttribute class is:</p>
  
  <pre><code>public class ValueFieldAttribute : ElasticPropertyAttribute
  {
      public ValueFieldAttribute()
          : base()
      {
          this.Store = false;
          this.Index = FieldIndexOption.not_analyzed;
      }
  }
  </code></pre>
  
  <p>My program:</p>
  
  <pre><code>    static void Main(string[] args)
      {
          ConnectionSettings node = new ConnectionSettings(new Uri("http://localhost:9200"));
          node.SetDefaultIndex("jobs");
          ElasticClient client = new ElasticClient(node);
  
          List&lt;JobProfessionalFieldInfo&gt; list = new List&lt;JobProfessionalFieldInfo&gt;();
          list.Add(new JobProfessionalFieldInfo { CategoryId = 1, JobId = 1 });
          list.Add(new JobProfessionalFieldInfo { CategoryId = 2, JobId = 2 });
          var res = client.Index&lt;MyJob&gt;(new MyJob
          {
              jobCode = 1,
              JobProfessionalFields = list
          },"jobs", "MyJob",1);
      }
  </code></pre>
  
  <p>Now, when I run it, it indexes the object successfully... BUT(!!) when I get the mapping of the index with GET jobs/MyJob/_mapping, I see that jobProfessionalFields has no "type":"nested" in its mapping.</p>
  
  <p>That results in a query like the following one, returning the indexed doc while it's not supposed to get it back (that's what nested-type is for right?..):</p>
  
  <pre><code>GET jobs/_search
  {
      "query": 
      {
          "bool": 
          {
              "must": 
              [
                 {"match": {"jobId":1}},
                 {"match": {"categoryId":2}}               
              ]
          }
      }    
  }
  </code></pre>
  
  <p>It's not the end:
  I'd a look at <a href="https://stackoverflow.com/questions/13218346/facet-on-nested-field-with-elasticsearch-c-sharp-mpdreamz-nest-client">here</a>,
  there the guy that answered tells that when we use annotations we need to manually call the createIndex and Map methods, but the problem is that I don't have any generic Map method...!
  Take a look at <a href="https://searchcode.com/codesearch/view/26606120/" rel="nofollow noreferrer">here</a>: (just to make you get into the link - here's its start..)</p>
  
  <pre><code>namespace Nest
  {
      public partial class ElasticClient...
  </code></pre>
  
  <p>And I don't know how to use the non-generic Map  method to put the mapping of my MyJob class.</p>
  
  <p>How can I cause this stuff to map the jobProfessionalFields as nested-type dudes?</p>
  
  <p>Thanks for any help of you guys!</p>