diff --git a/metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java b/metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java index dd36f0a9456a7..bff6ebdd317c4 100644 --- a/metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java +++ b/metadata-io/src/main/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformer.java @@ -287,8 +287,10 @@ public void setSearchableValue( .forEach( fieldValue -> { String[] keyValues = fieldValue.toString().split("="); - String key = keyValues[0]; - String value = keyValues[1]; + String key = keyValues[0], value = ""; + if (keyValues.length > 1) { + value = keyValues[1]; + } dictDoc.put(key, value); }); searchDocument.set(fieldName, dictDoc); diff --git a/metadata-io/src/test/java/com/linkedin/metadata/TestEntityUtil.java b/metadata-io/src/test/java/com/linkedin/metadata/TestEntityUtil.java index 9ee4a16a3ab99..062041253aa1f 100644 --- a/metadata-io/src/test/java/com/linkedin/metadata/TestEntityUtil.java +++ b/metadata-io/src/test/java/com/linkedin/metadata/TestEntityUtil.java @@ -65,6 +65,8 @@ public static TestEntityInfo getTestEntityInfo(Urn urn) { "value1", "key2", "value2", + "key3", + "", "shortValue", "123", "longValue", diff --git a/metadata-io/src/test/java/com/linkedin/metadata/extractor/FieldExtractorTest.java b/metadata-io/src/test/java/com/linkedin/metadata/extractor/FieldExtractorTest.java index 1adb5d1ab3952..f37f99c7bea60 100644 --- a/metadata-io/src/test/java/com/linkedin/metadata/extractor/FieldExtractorTest.java +++ b/metadata-io/src/test/java/com/linkedin/metadata/extractor/FieldExtractorTest.java @@ -57,7 +57,8 @@ public void testExtractor() { ImmutableList.of("key1=value1", "key2=value2", "shortValue=123", "longValue=0123456789")); assertEquals( result.get(nameToSpec.get("esObjectField")), - ImmutableList.of("key1=value1", "key2=value2", "shortValue=123", "longValue=0123456789")); + ImmutableList.of( + "key1=value1", "key2=value2", "shortValue=123", "key3=", "longValue=0123456789")); } @Test @@ -99,9 +100,6 @@ public void testExtractorMaxValueLength() { result.get(nameToSpec.get("customProperties")), ImmutableList.of(), "Expected no matching values because of value limit of 1"); - assertEquals( - result.get(nameToSpec.get("esObjectField")), - ImmutableList.of(), - "Expected no matching values because of value limit of 1"); + assertEquals(result.get(nameToSpec.get("esObjectField")), ImmutableList.of("key3=")); } } diff --git a/metadata-io/src/test/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformerTest.java b/metadata-io/src/test/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformerTest.java index 63550ca6c5dc5..48b1fb99d4e6d 100644 --- a/metadata-io/src/test/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformerTest.java +++ b/metadata-io/src/test/java/com/linkedin/metadata/search/transformer/SearchDocumentTransformerTest.java @@ -85,6 +85,7 @@ public void testTransform() throws IOException { assertEquals(parsedJson.get("feature2").asInt(), 1); JsonNode browsePathV2 = (JsonNode) parsedJson.get("browsePathV2"); assertEquals(browsePathV2.asText(), "␟levelOne␟levelTwo"); + assertEquals(parsedJson.get("esObjectField").get("key3").asText(), ""); } @Test @@ -125,7 +126,8 @@ public void testTransformMaxFieldValue() throws IOException { assertEquals( parsedJson.get("customProperties"), JsonNodeFactory.instance.arrayNode().add("shortValue=123")); - assertEquals(parsedJson.get("esObjectField"), JsonNodeFactory.instance.arrayNode().add("123")); + assertEquals( + parsedJson.get("esObjectField"), JsonNodeFactory.instance.arrayNode().add("123").add("")); searchDocumentTransformer = new SearchDocumentTransformer(1000, 1000, 20); snapshot = TestEntityUtil.getSnapshot(); @@ -149,6 +151,7 @@ public void testTransformMaxFieldValue() throws IOException { .add("value1") .add("value2") .add("123") + .add("") .add("0123456789")); }