From 7006c97b5e63a692a1bd4697cc63e768e14aaf8a Mon Sep 17 00:00:00 2001 From: Sanjana679 Date: Wed, 8 Nov 2023 09:00:15 -0500 Subject: [PATCH] Treat dot as nested field in field_map for inference processor Signed-off-by: Sanjana679 --- .../neuralsearch/processor/InferenceProcessor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java index 19944c11b..5d20eba78 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java @@ -154,6 +154,16 @@ Map buildMapWithProcessorKeyAndOriginalValue(IngestDocument inge for (Map.Entry fieldMapEntry : fieldMap.entrySet()) { String originalKey = fieldMapEntry.getKey(); Object targetKey = fieldMapEntry.getValue(); + + int nestedDotIndex = originalKey.indexOf('.'); + if (nestedDotIndex != -1) { + Map temp = new LinkedHashMap<>(); + temp.put(originalKey.substring(nestedDotIndex + 1), targetKey); + targetKey = temp; + + originalKey = originalKey.substring(0, nestedDotIndex); + } + if (targetKey instanceof Map) { Map treeRes = new LinkedHashMap<>(); buildMapWithProcessorKeyAndOriginalValueForMapType(originalKey, targetKey, sourceAndMetadataMap, treeRes);