@Before
 public void before() {
   clean();
   elasticsearchTemplate.createIndex(ParentEntity.class);
   elasticsearchTemplate.createIndex(ChildEntity.class);
   elasticsearchTemplate.putMapping(ParentEntity.class);
   elasticsearchTemplate.putMapping(ChildEntity.class);
 }
  @Before
  public void before() {
    elasticsearchTemplate.deleteIndex(Article.class);
    elasticsearchTemplate.createIndex(Article.class);
    elasticsearchTemplate.putMapping(Article.class);
    elasticsearchTemplate.refresh(Article.class, true);

    Article article = new Article("Spring Data Elasticsearch");
    article.setAuthors(asList(johnSmith, johnDoe));
    article.setTags("elasticsearch", "spring data");
    articleService.save(article);

    article = new Article("Search engines");
    article.setAuthors(asList(johnDoe));
    article.setTags("search engines", "tutorial");
    articleService.save(article);

    article = new Article("Second Article About Elasticsearch");
    article.setAuthors(asList(johnSmith));
    article.setTags("elasticsearch", "spring data");
    articleService.save(article);

    article = new Article("Elasticsearch Tutorial");
    article.setAuthors(asList(johnDoe));
    article.setTags("elasticsearch");
    articleService.save(article);
  }
 @Test
 public void shouldPutMappingForGivenEntity() throws Exception {
   // given
   Class entity = SampleMappingEntity.class;
   elasticsearchTemplate.createIndex(entity);
   // when
   assertThat(elasticsearchTemplate.putMapping(entity), is(true));
 }
 @Test
 public void shouldNotFailOnCircularReference() {
   elasticsearchTemplate.createIndex(SimpleRecursiveEntity.class);
   elasticsearchTemplate.putMapping(SimpleRecursiveEntity.class);
 }