title: Spring data elasticsearch, Failed to find nested object under path
body: <p>I am trying to use Spring data elastic search.
  I also read this <a href="https://stackoverflow.com/questions/18831882/spring-data-elastic-search-with-nested-fields-and-mapping">Spring Data Elastic Search with Nested Fields and mapping</a></p>
  
  <p>Getting the following exception.</p>
  
  <blockquote>
    <p>Caused by: org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], all shards failed; shardFailures {[-EbBygdLRkKs49wqsf5ewQ][support_team_idx][0]: RemoteTransportException[[Artie][local[6]][indices:data/read/search[phase/dfs]]]; nested: SearchParseException[[support_team_idx][0]: from[0],size[10]: Parse Failure [Failed to parse source [{"from":0,"size":10,"query":{"nested":{"query":{"bool":{"must":[{"term":{"supportteam.name":"test"}},{"term":{"supportteam.description":"test"}}]}},"path":"SupportTeam"}}}]]]; nested: QueryParsingException[[support_team_idx] [nested] failed to find nested object under path [SupportTeam]]; }</p>
  </blockquote>
  
  <p>Entity:</p>
  
  <pre><code>  @Document(indexName = "support_team_idx", type = "support_team_type", indexStoreType= "memory", shards = 1, replicas = 0,  refreshInterval = "-1")
  public class SupportTeam extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
  
    @Field(type=FieldType.String, index=FieldIndex.analyzed)
    private String name;
    @Field(type=FieldType.String, index=FieldIndex.analyzed)
    private String description;
  
    @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE})
    @JoinColumn(name = "org_unit_id", unique = false)
    @Field(type=FieldType.Nested)
    private OrgUnit orgUnit;
  
    @OneToMany(mappedBy = "supportTeam", fetch = FetchType.EAGER)
    @Field(type = FieldType.Nested)
    private Set&lt;SupportTeamMember&gt; supportTeamMembers;
  
    public SupportTeam() {}
   }
  
  log.info("Initializing Indexs");
      RootConfig.elasticsearchTemplate().deleteIndex(SupportTeam.class);
      RootConfig.elasticsearchTemplate().createIndex(SupportTeam.class);
      RootConfig.elasticsearchTemplate().putMapping(SupportTeam.class);
      RootConfig.elasticsearchTemplate().refresh(SupportTeam.class, true);
  </code></pre>
  
  <p>....</p>
  
  <pre><code> SearchQuery searchQuery = new NativeSearchQueryBuilder()
   .withQuery(nestedQuery("SupportTeam",           
    boolQuery().must(termQuery("supportteam.name", .
    searchText)).must(termQuery("supportteam.description", searchText))))
   .withIndices("support_team_idx").build();
  </code></pre>