Skip to content

Commit

Permalink
Added validation for nested fields in field_map
Browse files Browse the repository at this point in the history
Signed-off-by: Sanjana679 <[email protected]>
  • Loading branch information
Sanjana679 committed Nov 13, 2023
1 parent a5b1c4a commit 0e38fea
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.opensearch.neuralsearch.processor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -82,7 +83,9 @@ private void validateEmbeddingConfiguration(Map<String, Object> fieldMap) {
|| fieldMap.entrySet()
.stream()
.anyMatch(
x -> StringUtils.isBlank(x.getKey()) || Objects.isNull(x.getValue())
x -> StringUtils.startsWith(x.getKey(), ".") || StringUtils.endsWith(x.getKey(), ".")
|| Arrays.stream(x.getKey().split("\\.")).anyMatch(y -> StringUtils.isBlank(y))
|| Objects.isNull(x.getValue())
|| StringUtils.isBlank(x.getValue().toString()))) {
throw new IllegalArgumentException("Unable to create the processor as field_map has invalid key or value");
}
Expand Down

0 comments on commit 0e38fea

Please sign in to comment.