Skip to content

Commit a2338d7

Browse files
authored
Fix encoding of dynamic arrays in ignored source (elastic#112713) (elastic#112716)
1 parent e1e9e83 commit a2338d7

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
@@ -639,7 +639,7 @@ private static void parseArrayDynamic(DocumentParserContext context, String curr
639639
context.addIgnoredField(
640640
IgnoredSourceFieldMapper.NameValue.fromContext(
641641
context,
642-
currentFieldName,
642+
context.path().pathAsText(currentFieldName),
643643
XContentDataHelper.encodeToken(context.parser())
644644
)
645645
);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ public void testMultipleIgnoredFieldsManyObjects() throws IOException {
213213
);
214214
}
215215

216+
public void testIgnoredDynamicArrayNestedInObject() throws IOException {
217+
int intValue = randomInt();
218+
219+
String syntheticSource = getSyntheticSourceWithFieldLimit(b -> {
220+
b.startObject("bar");
221+
b.field("a", List.of(intValue, intValue));
222+
b.endObject();
223+
});
224+
assertEquals(String.format(Locale.ROOT, """
225+
{"bar":{"a":[%s,%s]}}""", intValue, intValue), syntheticSource);
226+
}
227+
216228
public void testDisabledRootObjectSingleField() throws IOException {
217229
String name = randomAlphaOfLength(20);
218230
DocumentMapper documentMapper = createMapperService(topMapping(b -> {

0 commit comments

Comments
 (0)