public void testDefaultNotAppliedOnUpdate() throws Exception {
XContentBuilder defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING)
.startObject("_source").array("includes", "default_field_path.").endObject()
.endObject().endObject();
IndexService indexService = createIndex("test", ImmutableSettings.EMPTY, MapperService.DEFAULT_MAPPING, defaultMapping);
String mapping = XContentFactory.jsonBuilder().startObject().startObject("my_type")
.startObject("_source").array("includes", "custom_field_path.").endObject()
.endObject().endObject().string();
client().admin().indices().preparePutMapping("test").setType("my_type").setSource(mapping).get();
DocumentMapper mapper = indexService.mapperService().documentMapper("my_type");
assertThat(mapper.type(), equalTo("my_type"));
assertThat(mapper.sourceMapper().includes().length, equalTo(2));
List<String> includes = Arrays.asList(mapper.sourceMapper().includes());
assertThat("default_field_path.", isIn(includes));
assertThat("custom_field_path.", isIn(includes));
mapping = XContentFactory.jsonBuilder().startObject().startObject("my_type")
.startObject("properties").startObject("text").field("type", "string").endObject().endObject()
.endObject().endObject().string();
client().admin().indices().preparePutMapping("test").setType("my_type").setSource(mapping).get();
mapper = indexService.mapperService().documentMapper("my_type");
assertThat(mapper.type(), equalTo("my_type"));
includes = Arrays.asList(mapper.sourceMapper().includes());
assertThat("default_field_path.", isIn(includes));
assertThat("custom_field_path.", isIn(includes));
assertThat(mapper.sourceMapper().includes().length, equalTo(2));