Skip to content

Commit af9acfb

Browse files
authored
Disable _parent field on new indices (#34259)
Today it is still possible to set a `_parent` field on an index created in 6x. This is accepted because the `_parent` field can refer to an non-existing type when it is created. However these indices cannot have more than one type so it doesn't make sense to create this field if it's not possible to create the parent type afterward. For this reason this change forbids `_parent` fields on indices created in 6.5. It also moves the yaml tests that use a parent field into the LegacyParentFieldMapperTests class where we can force the index version. Closes #33752
1 parent 9e3e7e1 commit af9acfb

29 files changed

+165
-848
lines changed

modules/parent-join/src/test/java/org/elasticsearch/join/query/ChildQuerySearchIT.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@
8787
import static org.hamcrest.Matchers.is;
8888

8989
public class ChildQuerySearchIT extends ParentChildTestCase {
90-
91-
public void testSelfReferentialIsForbidden() {
92-
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () ->
93-
prepareCreate("test").addMapping("type", "_parent", "type=type").get());
94-
assertThat(e.getMessage(), equalTo("The [_parent.type] option can't point to the same type"));
95-
}
96-
9790
public void testMultiLevelChild() throws Exception {
9891
if (legacy()) {
9992
assertAcked(prepareCreate("test")

modules/parent-join/src/test/java/org/elasticsearch/join/query/LegacyChildQuerySearchIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ protected boolean legacy() {
5454
return true;
5555
}
5656

57+
public void testSelfReferentialIsForbidden() {
58+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () ->
59+
prepareCreate("test").addMapping("type", "_parent", "type=type").get());
60+
assertThat(e.getMessage(), equalTo("The [_parent.type] option can't point to the same type"));
61+
}
62+
5763
public void testIndexChildDocWithNoParentMapping() throws IOException {
5864
assertAcked(prepareCreate("test")
5965
.addMapping("parent")

rest-api-spec/src/main/resources/rest-api-spec/test/create/50_parent.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/create/55_parent_with_routing.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/delete/40_parent.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/delete/42_missing_parent.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/delete/45_parent_with_routing.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/exists/30_parent.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/exists/55_parent_with_routing.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/get/30_parent.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)