title: Spring-data-elasticsearch nested query not working
body: <p><strong>Person.java</strong> </p>
  
  <pre><code>@Document(indexName = "person", type = "user")
  public class Person {
  
      @Id
      private String id;
  
      @Field(type = FieldType.String)
      private String name;
  
      @Field(type = FieldType.Nested)
      private List&lt;Car&gt; cars;
  
  // getter/setter
  
  }
  </code></pre>
  
  <p><strong>Car.java</strong></p>
  
  <pre><code>public class Car {
  
      @Field(type = FieldType.String)
      private String name;
  
      @Field(type = FieldType.String)
      private String model;
  
  // getter/setter
  }
  </code></pre>
  
  <p>Indexing and Searching using main method</p>
  
  <pre><code>public class SpringElasticSearchTest {
  
      public static void main(String[] args) {
  
          ApplicationContext applicationContext = new FileSystemXmlApplicationContext(
                  "src/main/webapp/WEB-INF/spring/applicationContext.xml");
  
          ElasticsearchTemplate est = (ElasticsearchTemplate) applicationContext
                  .getBean("elasticsearchTemplate");
  
          Person pers = new Person();
          pers.setName("Manish");
          pers.setId("1");
  
          List&lt;Car&gt; cars = new ArrayList&lt;Car&gt;();
          Car subaru = new Car();
          subaru.setName("Tata");
          subaru.setModel("Safari");
          cars.add(subaru);
          pers.setCars(cars);
  
          IndexQuery indexQuery = new IndexQuery();
          indexQuery.setId(pers.getId());
          indexQuery.setObject(pers);
  
          est.deleteIndex("person");
  
          est.createIndex(Person.class);
          est.putMapping(Person.class);
          est.index(indexQuery);
          est.refresh(Person.class, true);
  
          QueryBuilder builder = nestedQuery(
                  "cars",
                  boolQuery().must(termQuery("cars.name", "Tata")).must(
                          termQuery("cars.model", "Safari")));
          SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(
                  builder).build();
          List&lt;Person&gt; persons = est.queryForList(searchQuery, Person.class);
          System.out.println("Person List : " + persons);
  
      }
  </code></pre>
  
  <p>Indexing is working fine but searching functionally is not working.<br>
  I am getting the following output:</p>
  
  <blockquote>
    <p>Person List : []</p>
  </blockquote>
  
  <p>Please suggest.
  Thanks in advance.</p>