elasticsearchTemplate.refresh(ParentEntity.class, true);
elasticsearchTemplate.refresh(ChildEntity.class, true);
// find all parents that have the first child using topChildren Query
QueryBuilder query = topChildrenQuery(ParentEntity.CHILD_TYPE, QueryBuilders.termQuery("name", child1name.toLowerCase()));
List<ParentEntity> parents = elasticsearchTemplate.queryForList(new NativeSearchQuery(query), ParentEntity.class);
// we're expecting only the first parent as result
assertThat("parents", parents, contains(hasProperty("id", is(parent1.getId()))));
}