Skip to content

Commit 48f87c5

Browse files
authored
Fix encoding of dynamic arrays in ignored source (#112713)
1 parent f6ace50 commit 48f87c5

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

docs/changelog/112713.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 112713
2+
summary: Fix encoding of dynamic arrays in ignored source
3+
area: Logs
4+
type: bug
5+
issues: []

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ private static void parseArrayDynamic(DocumentParserContext context, String curr
646646
context.addIgnoredField(
647647
IgnoredSourceFieldMapper.NameValue.fromContext(
648648
context,
649-
currentFieldName,
649+
context.path().pathAsText(currentFieldName),
650650
XContentDataHelper.encodeToken(context.parser())
651651
)
652652
);

server/src/test/java/org/elasticsearch/index/mapper/IgnoredSourceFieldMapperTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ public void testMultipleIgnoredFieldsManyObjects() throws IOException {
221221
);
222222
}
223223

224+
public void testIgnoredDynamicArrayNestedInObject() throws IOException {
225+
int intValue = randomInt();
226+
227+
String syntheticSource = getSyntheticSourceWithFieldLimit(b -> {
228+
b.startObject("bar");
229+
b.field("a", List.of(intValue, intValue));
230+
b.endObject();
231+
});
232+
assertEquals(String.format(Locale.ROOT, """
233+
{"bar":{"a":[%s,%s]}}""", intValue, intValue), syntheticSource);
234+
}
235+
224236
public void testDisabledRootObjectSingleField() throws IOException {
225237
String name = randomAlphaOfLength(20);
226238
DocumentMapper documentMapper = createMapperService(topMapping(b -> {

0 commit comments

Comments
 (0)