|
@@ -578,13 +578,39 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
})).documentMapper();
|
|
|
var syntheticSource = syntheticSource(documentMapper, b -> {
|
|
|
b.startArray("path");
|
|
|
+ b.startObject().field("int_value", 20).endObject();
|
|
|
b.startObject().field("int_value", 10).endObject();
|
|
|
+ b.endArray();
|
|
|
+ b.field("bool_value", true);
|
|
|
+ });
|
|
|
+ assertEquals("""
|
|
|
+ {"bool_value":true,"path":[{"int_value":20},{"int_value":10}]}""", syntheticSource);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testIndexStoredArraySourceRootObjectArrayWithBypass() throws IOException {
|
|
|
+ DocumentMapper documentMapper = createMapperServiceWithStoredArraySource(syntheticSourceMapping(b -> {
|
|
|
+ b.startObject("path");
|
|
|
+ {
|
|
|
+ b.field("type", "object");
|
|
|
+ b.field("synthetic_source_keep", "none");
|
|
|
+ b.startObject("properties");
|
|
|
+ {
|
|
|
+ b.startObject("int_value").field("type", "integer").endObject();
|
|
|
+ }
|
|
|
+ b.endObject();
|
|
|
+ }
|
|
|
+ b.endObject();
|
|
|
+ b.startObject("bool_value").field("type", "boolean").endObject();
|
|
|
+ })).documentMapper();
|
|
|
+ var syntheticSource = syntheticSource(documentMapper, b -> {
|
|
|
+ b.startArray("path");
|
|
|
b.startObject().field("int_value", 20).endObject();
|
|
|
+ b.startObject().field("int_value", 10).endObject();
|
|
|
b.endArray();
|
|
|
b.field("bool_value", true);
|
|
|
});
|
|
|
assertEquals("""
|
|
|
- {"bool_value":true,"path":[{"int_value":10},{"int_value":20}]}""", syntheticSource);
|
|
|
+ {"bool_value":true,"path":{"int_value":[10,20]}}""", syntheticSource);
|
|
|
}
|
|
|
|
|
|
public void testIndexStoredArraySourceNestedValueArray() throws IOException {
|
|
@@ -622,6 +648,12 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
{
|
|
|
b.startObject("int_value").field("type", "integer").field(Mapper.SYNTHETIC_SOURCE_KEEP_PARAM, "none").endObject();
|
|
|
b.startObject("bool_value").field("type", "boolean").endObject();
|
|
|
+ b.startObject("obj").field("type", "object").field(Mapper.SYNTHETIC_SOURCE_KEEP_PARAM, "none");
|
|
|
+ b.startObject("properties");
|
|
|
+ {
|
|
|
+ b.startObject("foo").field("type", "integer").endObject();
|
|
|
+ }
|
|
|
+ b.endObject().endObject();
|
|
|
}
|
|
|
b.endObject();
|
|
|
}
|
|
@@ -632,11 +664,17 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
{
|
|
|
b.array("int_value", new int[] { 30, 20, 10 });
|
|
|
b.field("bool_value", true);
|
|
|
+ b.startArray("obj");
|
|
|
+ {
|
|
|
+ b.startObject().field("foo", 2).endObject();
|
|
|
+ b.startObject().field("foo", 1).endObject();
|
|
|
+ }
|
|
|
+ b.endArray();
|
|
|
}
|
|
|
b.endObject();
|
|
|
});
|
|
|
assertEquals("""
|
|
|
- {"path":{"bool_value":true,"int_value":[10,20,30]}}""", syntheticSource);
|
|
|
+ {"path":{"bool_value":true,"int_value":[10,20,30],"obj":{"foo":[1,2]}}}""", syntheticSource);
|
|
|
}
|
|
|
|
|
|
public void testFieldStoredArraySourceNestedValueArray() throws IOException {
|
|
@@ -674,8 +712,8 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.field("type", "object");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
- b.startObject("default").field("type", "float").field(Mapper.SYNTHETIC_SOURCE_KEEP_PARAM, "none").endObject();
|
|
|
- b.startObject("source_kept").field("type", "float").field(Mapper.SYNTHETIC_SOURCE_KEEP_PARAM, "all").endObject();
|
|
|
+ b.startObject("default").field("type", "float").field("synthetic_source_keep", "none").endObject();
|
|
|
+ b.startObject("source_kept").field("type", "float").field("synthetic_source_keep", "all").endObject();
|
|
|
b.startObject("bool_value").field("type", "boolean").endObject();
|
|
|
}
|
|
|
b.endObject();
|
|
@@ -738,7 +776,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.startObject("path");
|
|
|
{
|
|
|
b.field("type", "object");
|
|
|
- b.field("store_array_source", true);
|
|
|
+ b.field("synthetic_source_keep", "arrays");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
b.startObject("int_value").field("type", "integer").endObject();
|
|
@@ -765,7 +803,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.field("type", "object");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
- b.startObject("to").field("type", "object").field("store_array_source", true);
|
|
|
+ b.startObject("to").field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
{
|
|
|
b.startObject("properties");
|
|
|
{
|
|
@@ -835,10 +873,10 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
b.startObject("path");
|
|
|
{
|
|
|
- b.field("type", "object").field("store_array_source", true);
|
|
|
+ b.field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
- b.startObject("to").field("type", "object").field("store_array_source", true);
|
|
|
+ b.startObject("to").field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
{
|
|
|
b.startObject("properties");
|
|
|
{
|
|
@@ -893,7 +931,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
{
|
|
|
b.startObject("stored");
|
|
|
{
|
|
|
- b.field("type", "object").field("store_array_source", true);
|
|
|
+ b.field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
b.startObject("properties").startObject("leaf").field("type", "integer").endObject().endObject();
|
|
|
}
|
|
|
b.endObject();
|
|
@@ -1061,7 +1099,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.field("type", "object");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
- b.startObject("to").field("type", "object").field("store_array_source", true);
|
|
|
+ b.startObject("to").field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
{
|
|
|
b.startObject("properties");
|
|
|
{
|
|
@@ -1107,6 +1145,42 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
{"path":{"to":[{"name":"A"},{"name":"B"},{"name":"C"},{"name":"D"}]}}""", booleanValue), syntheticSource);
|
|
|
}
|
|
|
|
|
|
+ public void testObjectWithKeepAll() throws IOException {
|
|
|
+ DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
+ b.startObject("path");
|
|
|
+ {
|
|
|
+ b.field("type", "object").field("synthetic_source_keep", "all");
|
|
|
+ b.startObject("properties");
|
|
|
+ {
|
|
|
+ b.startObject("a").field("type", "object").endObject();
|
|
|
+ b.startObject("b").field("type", "integer").endObject();
|
|
|
+ }
|
|
|
+ b.endObject();
|
|
|
+ }
|
|
|
+ b.endObject();
|
|
|
+ b.startObject("id").field("type", "integer").endObject();
|
|
|
+ })).documentMapper();
|
|
|
+ var syntheticSource = syntheticSource(documentMapper, b -> {
|
|
|
+ b.startObject("path");
|
|
|
+ {
|
|
|
+ b.startArray("a");
|
|
|
+ {
|
|
|
+ b.startObject().field("foo", 30).endObject();
|
|
|
+ b.startObject().field("foo", 20).endObject();
|
|
|
+ b.startObject().field("foo", 10).endObject();
|
|
|
+ b.startObject().field("bar", 20).endObject();
|
|
|
+ b.startObject().field("bar", 10).endObject();
|
|
|
+ }
|
|
|
+ b.endArray();
|
|
|
+ b.array("b", 4, 1, 3, 2);
|
|
|
+ }
|
|
|
+ b.endObject();
|
|
|
+ b.field("id", 10);
|
|
|
+ });
|
|
|
+ assertEquals("""
|
|
|
+ {"id":10,"path":{"a":[{"foo":30},{"foo":20},{"foo":10},{"bar":20},{"bar":10}],"b":[4,1,3,2]}}""", syntheticSource);
|
|
|
+ }
|
|
|
+
|
|
|
public void testFallbackFieldWithinHigherLevelArray() throws IOException {
|
|
|
DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
b.startObject("path");
|
|
@@ -1140,7 +1214,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
public void testFieldOrdering() throws IOException {
|
|
|
DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
b.startObject("A").field("type", "integer").endObject();
|
|
|
- b.startObject("B").field("type", "object").field("store_array_source", true);
|
|
|
+ b.startObject("B").field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
{
|
|
|
b.startObject("properties");
|
|
|
{
|
|
@@ -1151,7 +1225,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
}
|
|
|
b.endObject();
|
|
|
b.startObject("C").field("type", "integer").endObject();
|
|
|
- b.startObject("D").field("type", "object").field("store_array_source", true);
|
|
|
+ b.startObject("D").field("type", "object").field("synthetic_source_keep", "arrays");
|
|
|
{
|
|
|
b.startObject("properties");
|
|
|
{
|
|
@@ -1189,7 +1263,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
b.startObject("path").field("type", "nested");
|
|
|
{
|
|
|
- b.field("store_array_source", true);
|
|
|
+ b.field("synthetic_source_keep", "all");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
b.startObject("foo").field("type", "keyword").endObject();
|
|
@@ -1211,7 +1285,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
b.startObject("path").field("type", "nested");
|
|
|
{
|
|
|
- b.field("store_array_source", true);
|
|
|
+ b.field("synthetic_source_keep", "all");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
b.startObject("foo").field("type", "keyword").endObject();
|
|
@@ -1244,7 +1318,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.startObject("int_value").field("type", "integer").endObject();
|
|
|
b.startObject("to").field("type", "nested");
|
|
|
{
|
|
|
- b.field("store_array_source", true);
|
|
|
+ b.field("synthetic_source_keep", "all");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
b.startObject("foo").field("type", "keyword").endObject();
|
|
@@ -1285,7 +1359,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.startObject("int_value").field("type", "integer").endObject();
|
|
|
b.startObject("to").field("type", "nested");
|
|
|
{
|
|
|
- b.field("store_array_source", true);
|
|
|
+ b.field("synthetic_source_keep", "all");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
b.startObject("foo").field("type", "keyword").endObject();
|
|
@@ -1325,7 +1399,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
|
|
|
public void testNestedObjectIncludeInRoot() throws IOException {
|
|
|
DocumentMapper documentMapper = createMapperService(syntheticSourceMapping(b -> {
|
|
|
- b.startObject("path").field("type", "nested").field("store_array_source", true).field("include_in_root", true);
|
|
|
+ b.startObject("path").field("type", "nested").field("synthetic_source_keep", "all").field("include_in_root", true);
|
|
|
{
|
|
|
b.startObject("properties");
|
|
|
{
|
|
@@ -1599,7 +1673,7 @@ public class IgnoredSourceFieldMapperTests extends MapperServiceTestCase {
|
|
|
b.startObject("path");
|
|
|
b.startObject("properties");
|
|
|
{
|
|
|
- b.startObject("at").field("type", "nested").field("store_array_source", "true").endObject();
|
|
|
+ b.startObject("at").field("type", "nested").field("synthetic_source_keep", "all").endObject();
|
|
|
}
|
|
|
b.endObject();
|
|
|
b.endObject();
|