Skip to content

Commit fe21d31

Browse files
Store full path in _ignored when ignoring dynamic array field (#136315) (#136324)
Currently, when a dynamic array field trips `index.mapping.total_fields. limit` and is ignored due to `index.mapping.total_fields. ignore_dynamic_beyond_limit`, the leaf name is stored in _ignored. This is inconsistent with single-valued fields where the full path is stored in _ignored. This PR updates the logic so that in both cases, the full path is stored.
1 parent 84a92dc commit fe21d31

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

docs/changelog/136315.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 136315
2+
summary: Store full path in `_ignored` when ignoring dynamic array field
3+
area: Mapping
4+
type: bug
5+
issues: []

server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ public void testIgnoreDynamicBeyondLimitObjectMultiField() {
383383
});
384384
}
385385

386+
public void testIgnoreDynamicBeyondLimitObjectArrayField() {
387+
indexIgnoreDynamicBeyond(2, orderedMap("a", orderedMap("b", 1, "c", List.of(2, 3, 4))), fields -> {
388+
assertThat(fields.keySet(), equalTo(Set.of("a.b", "_ignored")));
389+
assertThat(fields.get("a.b").getValues(), Matchers.contains(1L));
390+
assertThat(fields.get("_ignored").getValues(), Matchers.contains("a.c"));
391+
});
392+
}
393+
386394
public void testIgnoreDynamicBeyondLimitRuntimeFields() {
387395
indexIgnoreDynamicBeyond(1, orderedMap("field1", 1, "field2", List.of(1, 2)), Map.of("dynamic", "runtime"), fields -> {
388396
assertThat(fields.keySet(), equalTo(Set.of("field1", "_ignored")));

server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ private static void parseArrayDynamic(DocumentParserContext context, String curr
669669
throw new IllegalArgumentException("failed to parse field [" + currentFieldName + " ]", e);
670670
}
671671
}
672-
context.addIgnoredField(currentFieldName);
672+
context.addIgnoredField(context.path().pathAsText(currentFieldName));
673673
return;
674674
}
675675
parseNonDynamicArray(context, objectMapperFromTemplate, currentFieldName, currentFieldName);

0 commit comments

Comments
 (0)