-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat . as a nested field in field_map of text embedding processor #488
Changes from 2 commits
7006c97
2c7f491
a5b1c4a
0e38fea
2177ba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,16 @@ | |
for (Map.Entry<String, Object> fieldMapEntry : fieldMap.entrySet()) { | ||
String originalKey = fieldMapEntry.getKey(); | ||
Object targetKey = fieldMapEntry.getValue(); | ||
|
||
int nestedDotIndex = originalKey.indexOf('.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use a static constant and avoid magic characters in code.
|
||
if (nestedDotIndex != -1) { | ||
Map<String, Object> temp = new LinkedHashMap<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need this map object? Can you please use more meaningful name for map variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a more meaningful name for the map variable. |
||
temp.put(originalKey.substring(nestedDotIndex + 1), targetKey); | ||
targetKey = temp; | ||
Check warning on line 162 in src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java Codecov / codecov/patchsrc/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java#L160-L162
|
||
|
||
originalKey = originalKey.substring(0, nestedDotIndex); | ||
} | ||
|
||
if (targetKey instanceof Map) { | ||
Map<String, Object> treeRes = new LinkedHashMap<>(); | ||
buildMapWithProcessorKeyAndOriginalValueForMapType(originalKey, targetKey, sourceAndMetadataMap, treeRes); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a user-provided info, can we add basic validation if it's not already done as part of the processor/pipeline definition.
if multiple levels of nested fields are needed this code may need a rework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some basic validation done in
validateEmbeddingConfiguration
which is run onfieldMap
in the constructor in this file. However, I will add some extra validation for nested fields.