DATAES-531 - Fixed getMapping from ElasticsearchRestTemplate.

The getMapping methods in the ElasticsearchRestTemplate now behave like the methods in the ElasticsearchTemplate and return the mapping for the specified index and type.

Original pull request: #239
This commit is contained in:
Peter Nowak
2019-01-18 10:26:42 +01:00
committed by xhaggi
parent 69dc36c6c3
commit a89a44b08f
2 changed files with 19 additions and 5 deletions

View File

@@ -79,6 +79,7 @@ import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
* @author Sascha Woo
* @author Jean-Baptiste Nizet
* @author Zetang Zeng
* @author Peter Nowak
*/
@Ignore
@@ -2350,6 +2351,18 @@ public class ElasticsearchTemplateTests {
" tokenizer: uax_url_email\n"));
}
@Test // DATAES-531
public void shouldReturnMappingForGivenEntityClass() {
// when
boolean created = elasticsearchTemplate.createIndex(SampleEntity.class);
elasticsearchTemplate.putMapping(SampleEntity.class);
final Map mapping = elasticsearchTemplate.getMapping(SampleEntity.class);
// then
assertThat(created, is(true));
assertThat(mapping, notNullValue());
assertThat(((Map) ((Map) mapping.get("properties")).get("message")).get("type"), Matchers.<Object>is("text"));
}
private IndexQuery getIndexQuery(SampleEntity sampleEntity) {
return new IndexQueryBuilder()
.withId(sampleEntity.getId())