From 9acf74d58615cf9051f1fd54e1d0e8bc1eb20cc5 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Sat, 30 Nov 2024 17:32:49 +0000 Subject: [PATCH] iter --- .../index/mapper/InferenceMetadataFieldsMapper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/mapper/InferenceMetadataFieldsMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/InferenceMetadataFieldsMapper.java index b713ecada5237..ab58adff1ce06 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/InferenceMetadataFieldsMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/InferenceMetadataFieldsMapper.java @@ -75,8 +75,12 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio while (parser.nextToken() != XContentParser.Token.END_OBJECT) { XContentParserUtils.ensureExpectedToken(XContentParser.Token.FIELD_NAME, parser.currentToken(), parser); String fieldName = parser.currentName(); - // TODO: Find the leaf field under objects - Mapper mapper = context.mappingLookup().getMapper(fieldName); + var parent = context.parent().findParentMapper(fieldName); + if (parent == null) { + throw new IllegalArgumentException("Illegal inference field [" + fieldName + "] found."); + } + String suffix = context.parent() != parent ? fieldName.substring(parent.fullPath().length() + 1) : fieldName; + var mapper = parent.getMapper(suffix); if (mapper != null && mapper instanceof InferenceFieldMapper && mapper instanceof FieldMapper fieldMapper) { fieldMapper.parseCreateField(new DocumentParserContext.Wrapper(context.parent(), context) { @Override