Skip to content
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

Default normalizer deserialization to custom type when unspecified #1111

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected static void setupNormalizerDeserializer(ObjectDeserializer<Builder> 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());

}

Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}
Loading