forked from opensearch-project/opensearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default analyzer deserialization to custom type when unspecified (ope…
…nsearch-project#1033) * Default analyzer deserialization to custom type when unspecified Signed-off-by: Thomas Farr <[email protected]> * Add changelog Signed-off-by: Thomas Farr <[email protected]> * Fix for java8 Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Thomas Farr <[email protected]> (cherry picked from commit 80dc741)
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
.../test/java/org/opensearch/client/opensearch/_types/analysis/AnalyzerDeserializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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 AnalyzerDeserializerTest extends ModelTestCase { | ||
@Test | ||
public void deserializesTypelessCustomAnalyzer() { | ||
String json = "{\n" | ||
+ " \"filter\": [\"kuromoji_baseform\", \"ja_stop\"],\n" | ||
+ " \"char_filter\": [\"icu_normalizer\"],\n" | ||
+ " \"tokenizer\": \"kuromoji_tokenizer\"\n" | ||
+ "}"; | ||
|
||
Analyzer analyzer = fromJson(json, Analyzer._DESERIALIZER); | ||
assertTrue(analyzer.isCustom()); | ||
assertEquals("kuromoji_tokenizer", analyzer.custom().tokenizer()); | ||
assertEquals("icu_normalizer", analyzer.custom().charFilter().get(0)); | ||
assertEquals("kuromoji_baseform", analyzer.custom().filter().get(0)); | ||
assertEquals("ja_stop", analyzer.custom().filter().get(1)); | ||
} | ||
} |