|
@@ -25,6 +25,7 @@ import org.elasticsearch.common.compress.CompressedXContent;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.index.IndexService;
|
|
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
|
|
+import org.elasticsearch.index.mapper.MapperParsingException;
|
|
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
|
|
|
|
|
import java.util.Collections;
|
|
@@ -69,6 +70,15 @@ public class MetaDataMappingServiceTests extends ESSingleNodeTestCase {
|
|
|
assertThat(documentMapper.parentFieldMapper().active(), is(true));
|
|
|
}
|
|
|
|
|
|
+ public void testParentIsAString() throws Exception {
|
|
|
+ // Shouldn't be able the add the _parent field pointing to an already existing type, which isn't a parent type
|
|
|
+ Exception e = expectThrows(MapperParsingException.class, () -> client().admin().indices().prepareCreate("test")
|
|
|
+ .addMapping("parent", "{\"properties\":{}}")
|
|
|
+ .addMapping("child", "{\"_parent\": \"parent\",\"properties\":{}}")
|
|
|
+ .get());
|
|
|
+ assertEquals("Failed to parse mapping [child]: [_parent] must be an object containing [type]", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Exception {
|
|
|
final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type"));
|
|
|
final CompressedXContent currentMapping = indexService.mapperService().documentMapper("type").mappingSource();
|