|
@@ -111,7 +111,7 @@ public abstract class DocumentParserContext {
|
|
|
private final Set<String> ignoredFields;
|
|
|
private final List<IgnoredSourceFieldMapper.NameValue> ignoredFieldValues;
|
|
|
private final List<IgnoredSourceFieldMapper.NameValue> ignoredFieldsMissingValues;
|
|
|
- private String parentArrayField;
|
|
|
+ private boolean inArrayScope;
|
|
|
|
|
|
private final Map<String, List<Mapper>> dynamicMappers;
|
|
|
private final DynamicMapperSize dynamicMappersSize;
|
|
@@ -143,7 +143,7 @@ public abstract class DocumentParserContext {
|
|
|
Set<String> ignoreFields,
|
|
|
List<IgnoredSourceFieldMapper.NameValue> ignoredFieldValues,
|
|
|
List<IgnoredSourceFieldMapper.NameValue> ignoredFieldsWithNoSource,
|
|
|
- String parentArrayField,
|
|
|
+ boolean inArrayScope,
|
|
|
Map<String, List<Mapper>> dynamicMappers,
|
|
|
Map<String, ObjectMapper> dynamicObjectMappers,
|
|
|
Map<String, List<RuntimeField>> dynamicRuntimeFields,
|
|
@@ -164,7 +164,7 @@ public abstract class DocumentParserContext {
|
|
|
this.ignoredFields = ignoreFields;
|
|
|
this.ignoredFieldValues = ignoredFieldValues;
|
|
|
this.ignoredFieldsMissingValues = ignoredFieldsWithNoSource;
|
|
|
- this.parentArrayField = parentArrayField;
|
|
|
+ this.inArrayScope = inArrayScope;
|
|
|
this.dynamicMappers = dynamicMappers;
|
|
|
this.dynamicObjectMappers = dynamicObjectMappers;
|
|
|
this.dynamicRuntimeFields = dynamicRuntimeFields;
|
|
@@ -188,7 +188,7 @@ public abstract class DocumentParserContext {
|
|
|
in.ignoredFields,
|
|
|
in.ignoredFieldValues,
|
|
|
in.ignoredFieldsMissingValues,
|
|
|
- in.parentArrayField,
|
|
|
+ in.inArrayScope,
|
|
|
in.dynamicMappers,
|
|
|
in.dynamicObjectMappers,
|
|
|
in.dynamicRuntimeFields,
|
|
@@ -219,7 +219,7 @@ public abstract class DocumentParserContext {
|
|
|
new HashSet<>(),
|
|
|
new ArrayList<>(),
|
|
|
new ArrayList<>(),
|
|
|
- null,
|
|
|
+ false,
|
|
|
new HashMap<>(),
|
|
|
new HashMap<>(),
|
|
|
new HashMap<>(),
|
|
@@ -324,10 +324,7 @@ public abstract class DocumentParserContext {
|
|
|
public final DocumentParserContext addIgnoredFieldFromContext(IgnoredSourceFieldMapper.NameValue ignoredFieldWithNoSource)
|
|
|
throws IOException {
|
|
|
if (canAddIgnoredField()) {
|
|
|
- if (parentArrayField != null
|
|
|
- && parent != null
|
|
|
- && parentArrayField.equals(parent.fullPath())
|
|
|
- && parent instanceof NestedObjectMapper == false) {
|
|
|
+ if (inArrayScope) {
|
|
|
// The field is an array within an array, store all sub-array elements.
|
|
|
ignoredFieldsMissingValues.add(ignoredFieldWithNoSource);
|
|
|
return cloneWithRecordedSource();
|
|
@@ -364,14 +361,17 @@ public abstract class DocumentParserContext {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Clones the current context to mark it as an array. Records the full name of the array field, to check for sub-arrays.
|
|
|
+ * Clones the current context to mark it as an array, if it's not already marked, or restore it if it's within a nested object.
|
|
|
* Applies to synthetic source only.
|
|
|
*/
|
|
|
- public final DocumentParserContext cloneForArray(String fullName) throws IOException {
|
|
|
- if (canAddIgnoredField()) {
|
|
|
- DocumentParserContext subcontext = switchParser(parser());
|
|
|
- subcontext.parentArrayField = fullName;
|
|
|
- return subcontext;
|
|
|
+ public final DocumentParserContext maybeCloneForArray(Mapper mapper) throws IOException {
|
|
|
+ if (canAddIgnoredField() && mapper instanceof ObjectMapper) {
|
|
|
+ boolean isNested = mapper instanceof NestedObjectMapper;
|
|
|
+ if ((inArrayScope == false && isNested == false) || (inArrayScope && isNested)) {
|
|
|
+ DocumentParserContext subcontext = switchParser(parser());
|
|
|
+ subcontext.inArrayScope = inArrayScope == false;
|
|
|
+ return subcontext;
|
|
|
+ }
|
|
|
}
|
|
|
return this;
|
|
|
}
|