Skip to content

Commit

Permalink
bug fix for map type
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Feb 26, 2024
1 parent 3f0573a commit 3685ae7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ private void validateDocumentChunkingFieldMap(Map<String, Object> fieldMap) {
private void validateContent(Object content, String inputField) {
// content can be a map, a list of strings or a list
if (content instanceof Map) {
System.out.println("map type");
@SuppressWarnings("unchecked")
Map<String, Object> contentMap = (Map<String, Object>) content;
for (Map.Entry<String, Object> contentEntry : contentMap.entrySet()) {
Expand All @@ -137,32 +138,31 @@ private void validateContent(Object content, String inputField) {
// the map value can also be a map, list or string
validateContent(contentValue, inputField + "." + contentKey);
}
}
if (content instanceof List) {
} else if (content instanceof List) {
List<?> contentList = (List<?>) content;
for (Object contentElement : contentList) {
if (!(contentElement instanceof String)) {
throw new IllegalArgumentException(
"some element in input field list ["
+ inputField
+ "] of type ["
+ contentElement.getClass().getName()
+ "] cannot be cast to ["
+ String.class.getName()
+ "]"
"some element in input field list ["
+ inputField
+ "] of type ["
+ contentElement.getClass().getName()
+ "] cannot be cast to ["
+ String.class.getName()
+ "]"
);
}
}
}
if (!(content instanceof String)) {
throw new IllegalArgumentException(
"input field ["
+ inputField
+ "] of type ["
+ content.getClass().getName()
+ "] cannot be cast to ["
+ String.class.getName()
+ "]"
"input field ["
+ inputField
+ "] of type ["
+ content.getClass().getName()
+ "] cannot be cast to ["
+ String.class.getName()
+ "]"
);
}
}
Expand Down Expand Up @@ -191,7 +191,6 @@ private Object chunk(IFieldChunker chunker, Object content, Map<String, Object>
}
}


@Override
public IngestDocument execute(IngestDocument document) {
for (Map.Entry<String, Object> fieldMapEntry : fieldMap.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package org.opensearch.neuralsearch.processor;public class DocumentChunkingProcessorTests {
}

0 comments on commit 3685ae7

Please sign in to comment.