DATAES-305 - Allow to put mapping built from entity class to different index.

Original pull request: #319
This commit is contained in:
xhaggi
2019-09-12 09:56:00 +02:00
parent 6092da6fe7
commit 642d95b5d1
5 changed files with 97 additions and 42 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.data.elasticsearch.core;
import static org.apache.commons.lang.RandomStringUtils.*;
import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.hamcrest.CoreMatchers.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
@@ -1438,6 +1439,22 @@ public class ElasticsearchTemplateTests {
assertThat(elasticsearchTemplate.putMapping(entity)).isTrue();
}
@Test // DATAES-305
public void shouldPutMappingWithCustomIndexName() throws Exception {
// given
Class<SampleEntity> entity = SampleEntity.class;
elasticsearchTemplate.deleteIndex(INDEX_1_NAME);
elasticsearchTemplate.createIndex(INDEX_1_NAME);
// when
elasticsearchTemplate.putMapping(INDEX_1_NAME, TYPE_NAME, entity);
// then
Map<String, Object> mapping = elasticsearchTemplate.getMapping(INDEX_1_NAME, TYPE_NAME);
assertThat(mapping.get("properties")).isNotNull();
}
@Test
public void shouldDeleteIndexForGivenEntity() {