Skip to content

Commit

Permalink
Default normalizer deserialization to custom type when unspecified (#…
Browse files Browse the repository at this point in the history
…1111)

* Default normalizer deserialization to custom type when unspecified

Signed-off-by: beniamin.jedrychowsk <beniamin.jedrychowski@transatel.com>

* fix style

Signed-off-by: beniamin.jedrychowsk <beniamin.jedrychowski@transatel.com>

* Update CHANGELOG.md

fixed changelog formatting

Co-authored-by: Thomas Farr <xtansia@xtansia.com>
Signed-off-by: Beniamin Jędrychowski <beniamin.jedrychowski@transatel.com>

---------

Signed-off-by: beniamin.jedrychowsk <beniamin.jedrychowski@transatel.com>
Signed-off-by: Beniamin Jędrychowski <beniamin.jedrychowski@transatel.com>
Co-authored-by: Thomas Farr <xtansia@xtansia.com>
(cherry picked from commit 905aa34)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and Xtansia committed Jul 29, 2024
1 parent 725dbd3 commit 4ac63ce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Removed

### Fixed
- Fixed error when deserializing a normalizer without 'type' ([#1111](https://github.com/opensearch-project/opensearch-java/pull/1111))

### Security

Expand Down
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));
}
}

0 comments on commit 4ac63ce

Please sign in to comment.