diff --git a/CHANGELOG.md b/CHANGELOG.md index c6093bfe19..f91dd824b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Removed ### Fixed +- Fixed error when deserializing a normalizer without 'type' ([#1111](https://github.com/opensearch-project/opensearch-java/pull/1111)) ### Security @@ -512,4 +513,4 @@ This section is for maintaining a changelog for all breaking changes for the cli [2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0 [2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0 -[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 \ No newline at end of file +[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Normalizer.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Normalizer.java index de7342afcd..a357215809 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Normalizer.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Normalizer.java @@ -186,7 +186,7 @@ protected static void setupNormalizerDeserializer(ObjectDeserializer op op.add(Builder::custom, CustomNormalizer._DESERIALIZER, "custom"); op.add(Builder::lowercase, LowercaseNormalizer._DESERIALIZER, "lowercase"); - op.setTypeProperty("type", null); + op.setTypeProperty("type", Kind.Custom.jsonValue()); } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/_types/analysis/NormalizerDeserializerTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/_types/analysis/NormalizerDeserializerTest.java new file mode 100644 index 0000000000..5c9d7c7a13 --- /dev/null +++ b/java-client/src/test/java/org/opensearch/client/opensearch/_types/analysis/NormalizerDeserializerTest.java @@ -0,0 +1,24 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.opensearch._types.analysis; + +import org.junit.Test; +import org.opensearch.client.opensearch.model.ModelTestCase; + +public class NormalizerDeserializerTest extends ModelTestCase { + + @Test + public void deserializesTypelessCustomAnalyzer() { + String json = "{\n" + " \"filter\": \"lowercase\"\n" + " }"; + + Normalizer normalizer = fromJson(json, Normalizer._DESERIALIZER); + assertTrue(normalizer.isCustom()); + assertEquals("lowercase", normalizer.custom().filter().get(0)); + } +}