From a1a0b636a021f2b52f2699d5f24586bfb2903a72 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 22 Aug 2023 13:32:21 -0700 Subject: [PATCH] [Backport 2.x] Added "smartcn" and "cjk" analyzers (#607) * Added "smartcn" analyzer. (#605) * Added "smartcn" analyzer. Signed-off-by: pieper * Adapted changelog. Signed-off-by: pieper * Fixed license headers. Signed-off-by: pieper * Fixed release number. Signed-off-by: pieper --------- Signed-off-by: pieper Signed-off-by: Vacha Shah * Added "cjk" analyzer. (#604) * Added "cjk" analyzer. Signed-off-by: pieper * Adapted changelog. Signed-off-by: pieper * Fixed license headers. Signed-off-by: pieper * Tab vs. Spaces fix. Signed-off-by: pieper --------- Signed-off-by: pieper Signed-off-by: Vacha Shah --------- Signed-off-by: pieper Signed-off-by: Vacha Shah Co-authored-by: MikePieperSer <41434171+MikePieperSer@users.noreply.github.com> --- CHANGELOG.md | 4 +- .../opensearch/_types/analysis/Analyzer.java | 65 ++++++- .../_types/analysis/CjkAnalyzer.java | 182 ++++++++++++++++++ .../_types/analysis/SmartcnAnalyzer.java | 101 ++++++++++ .../analysis/SmartcnStopTokenFilter.java | 98 ++++++++++ .../_types/analysis/SmartcnTokenizer.java | 97 ++++++++++ .../analysis/TokenFilterDefinition.java | 16 +- .../_types/analysis/TokenizerDefinition.java | 16 +- .../opensearch/experiments/ParsingTests.java | 61 ++++++ 9 files changed, 636 insertions(+), 4 deletions(-) create mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CjkAnalyzer.java create mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnAnalyzer.java create mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnStopTokenFilter.java create mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnTokenizer.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 009ca7ae7d..45aee9f155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # CHANGELOG Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) -## [Unreleased 2.x](https://github.com/opensearch-project/opensearch-java/compare/v2.6.0...2.x) +## [Unreleased 2.x] ### Added +- Added support for "smartcn" analyzer ([#605](https://github.com/opensearch-project/opensearch-java/pull/605)) +- Added support for "cjk" analyzer ([#604](https://github.com/opensearch-project/opensearch-java/pull/604)) ### Dependencies - Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.0.0 to 5.2.0 diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Analyzer.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Analyzer.java index 66ba4d4de4..7ae36f4dcc 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Analyzer.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/Analyzer.java @@ -90,6 +90,10 @@ public enum Kind implements JsonEnum { Whitespace("whitespace"), + Smartcn("smartcn"), + + Cjk("cjk"), + ; private final String jsonValue; @@ -373,7 +377,43 @@ public WhitespaceAnalyzer whitespace() { return TaggedUnionUtils.get(this, Kind.Whitespace); } - @Override + /** + * Is this variant instance of kind {@code cjk}? + */ + public boolean isSmartcn() { + return _kind == Kind.Smartcn; + } + + /** + * Get the {@code cjk} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code cjk} kind. + */ + public SmartcnAnalyzer smartcn() { + return TaggedUnionUtils.get(this, Kind.Smartcn); + } + + + /** + * Is this variant instance of kind {@code cjk}? + */ + public boolean isCjk() { + return _kind == Kind.Cjk; + } + + /** + * Get the {@code cjk} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code cjk} kind. + */ + public CjkAnalyzer cjk() { + return TaggedUnionUtils.get(this, Kind.Cjk); + } + + + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { mapper.serialize(_value, generator); @@ -530,6 +570,27 @@ public ObjectBuilder whitespace( return this.whitespace(fn.apply(new WhitespaceAnalyzer.Builder()).build()); } + public ObjectBuilder smartcn(SmartcnAnalyzer v) { + this._kind = Kind.Smartcn; + this._value = v; + return this; + } + + public ObjectBuilder smartcn() { + return this.smartcn(new SmartcnAnalyzer.Builder().build()); + } + + public ObjectBuilder cjk(CjkAnalyzer v) { + this._kind = Kind.Cjk; + this._value = v; + return this; + } + + public ObjectBuilder cjk( + Function> fn) { + return this.cjk(fn.apply(new CjkAnalyzer.Builder()).build()); + } + public Analyzer build() { _checkSingleUse(); return new Analyzer(this); @@ -553,6 +614,8 @@ protected static void setupAnalyzerDeserializer(ObjectDeserializer op) op.add(Builder::standard, StandardAnalyzer._DESERIALIZER, "standard"); op.add(Builder::stop, StopAnalyzer._DESERIALIZER, "stop"); op.add(Builder::whitespace, WhitespaceAnalyzer._DESERIALIZER, "whitespace"); + op.add(Builder::smartcn, SmartcnAnalyzer._DESERIALIZER, Kind.Smartcn.jsonValue()); + op.add(Builder::cjk, CjkAnalyzer._DESERIALIZER, Kind.Cjk.jsonValue()); op.setTypeProperty("type", null); diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CjkAnalyzer.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CjkAnalyzer.java new file mode 100644 index 0000000000..421f6c4dd3 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/CjkAnalyzer.java @@ -0,0 +1,182 @@ +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.opensearch._types.analysis; + +import java.util.List; +import java.util.function.Function; + +import javax.annotation.Nullable; + +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +import jakarta.json.stream.JsonGenerator; + +// typedef: _types.analysis.LanguageAnalyzer + +@JsonpDeserializable +public class CjkAnalyzer implements AnalyzerVariant, JsonpSerializable { + @Nullable + private final List stopwords; + + @Nullable + private final String stopwordsPath; + + // --------------------------------------------------------------------------------------------- + + private CjkAnalyzer(Builder builder) { + + this.stopwords = ApiTypeHelper.unmodifiable(builder.stopwords); + this.stopwordsPath = builder.stopwordsPath; + + } + + public static CjkAnalyzer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Analyzer variant kind. + */ + @Override + public Analyzer.Kind _analyzerKind() { + return Analyzer.Kind.Cjk; + } + + /** + * API name: {@code stopwords} + */ + public final List stopwords() { + return this.stopwords; + } + + /** + * API name: {@code stopwords_path} + */ + @Nullable + public final String stopwordsPath() { + return this.stopwordsPath; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", Analyzer.Kind.Cjk.jsonValue()); + + + if (ApiTypeHelper.isDefined(this.stopwords)) { + generator.writeKey("stopwords"); + generator.writeStartArray(); + for (String item0 : this.stopwords) { + generator.write(item0); + + } + generator.writeEnd(); + + } + if (this.stopwordsPath != null) { + generator.writeKey("stopwords_path"); + generator.write(this.stopwordsPath); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link CjkAnalyzer}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private List stopwords; + + @Nullable + private String stopwordsPath; + + /** + * API name: {@code stopwords} + *

+ * Adds all elements of list to stopwords. + */ + public final Builder stopwords(List list) { + this.stopwords = _listAddAll(this.stopwords, list); + return this; + } + + /** + * API name: {@code stopwords} + *

+ * Adds one or more values to stopwords. + */ + public final Builder stopwords(String value, String... values) { + this.stopwords = _listAdd(this.stopwords, value, values); + return this; + } + + /** + * API name: {@code stopwords_path} + */ + public final Builder stopwordsPath(@Nullable String value) { + this.stopwordsPath = value; + return this; + } + + /** + * Builds a {@link CjkAnalyzer}. + * + * @throws NullPointerException + * if some required fields are null. + */ + public CjkAnalyzer build() { + _checkSingleUse(); + + return new CjkAnalyzer(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link CjkAnalyzer} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + CjkAnalyzer::setupLanguageAnalyzerDeserializer); + + protected static void setupLanguageAnalyzerDeserializer(ObjectDeserializer op) { + + op.add(Builder::stopwords, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "stopwords"); + op.add(Builder::stopwordsPath, JsonpDeserializer.stringDeserializer(), "stopwords_path"); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnAnalyzer.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnAnalyzer.java new file mode 100644 index 0000000000..11cee498cf --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnAnalyzer.java @@ -0,0 +1,101 @@ +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.opensearch._types.analysis; + +import java.util.function.Function; + +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +import jakarta.json.stream.JsonGenerator; + +// typedef: _types.analysis.LanguageAnalyzer + +@JsonpDeserializable +public class SmartcnAnalyzer implements AnalyzerVariant, JsonpSerializable { + + // --------------------------------------------------------------------------------------------- + + private SmartcnAnalyzer(Builder builder) { + + } + + public static SmartcnAnalyzer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Analyzer variant kind. + */ + @Override + public Analyzer.Kind _analyzerKind() { + return Analyzer.Kind.Smartcn; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", Analyzer.Kind.Smartcn.jsonValue()); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SmartcnAnalyzer}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + + /** + * Builds a {@link SmartcnAnalyzer}. + * + * @throws NullPointerException + * if some required fields are null. + */ + public SmartcnAnalyzer build() { + _checkSingleUse(); + + return new SmartcnAnalyzer(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SmartcnAnalyzer} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + SmartcnAnalyzer::setupLanguageAnalyzerDeserializer); + + protected static void setupLanguageAnalyzerDeserializer(ObjectDeserializer op) { + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnStopTokenFilter.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnStopTokenFilter.java new file mode 100644 index 0000000000..7e47454ec0 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnStopTokenFilter.java @@ -0,0 +1,98 @@ +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.opensearch._types.analysis; + +import java.util.function.Function; + +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; + +import jakarta.json.stream.JsonGenerator; + +// typedef: _types.analysis.ReverseTokenFilter + +@JsonpDeserializable +public class SmartcnStopTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { + // --------------------------------------------------------------------------------------------- + + private SmartcnStopTokenFilter(Builder builder) { + super(builder); + + } + + public static SmartcnStopTokenFilter of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * TokenFilterDefinition variant kind. + */ + @Override + public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { + return TokenFilterDefinition.Kind.SmartcnStop; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", TokenFilterDefinition.Kind.SmartcnStop.jsonValue()); + super.serializeInternal(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SmartcnStopTokenFilter}. + */ + + public static class Builder extends AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SmartcnStopTokenFilter}. + * + * @throws NullPointerException + * if some required fields are null. + */ + public SmartcnStopTokenFilter build() { + _checkSingleUse(); + + return new SmartcnStopTokenFilter(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SmartcnStopTokenFilter} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, SmartcnStopTokenFilter::setupSmartcnStopTokenFilterDeserializer); + + protected static void setupSmartcnStopTokenFilterDeserializer(ObjectDeserializer op) { + setupTokenFilterBaseDeserializer(op); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnTokenizer.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnTokenizer.java new file mode 100644 index 0000000000..f8d37e1bc7 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/SmartcnTokenizer.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.opensearch._types.analysis; + +import java.util.function.Function; + +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; + +import jakarta.json.stream.JsonGenerator; + +// typedef: _types.analysis.IcuTokenizer + +@JsonpDeserializable +public class SmartcnTokenizer extends TokenizerBase implements TokenizerDefinitionVariant { + // --------------------------------------------------------------------------------------------- + + private SmartcnTokenizer(Builder builder) { + super(builder); + + } + + public static SmartcnTokenizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * TokenizerDefinition variant kind. + */ + @Override + public TokenizerDefinition.Kind _tokenizerDefinitionKind() { + return TokenizerDefinition.Kind.SmartcnTokenizer; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", TokenizerDefinition.Kind.SmartcnTokenizer.jsonValue()); + super.serializeInternal(generator, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link SmartcnTokenizer}. + */ + + public static class Builder extends AbstractBuilder implements ObjectBuilder { + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link SmartcnTokenizer}. + * + * @throws NullPointerException + * if some required fields are null. + */ + public SmartcnTokenizer build() { + _checkSingleUse(); + + return new SmartcnTokenizer(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link SmartcnTokenizer} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + SmartcnTokenizer::setupSmartcnTokenizerDeserializer); + + protected static void setupSmartcnTokenizerDeserializer(ObjectDeserializer op) { + TokenizerBase.setupTokenizerBaseDeserializer(op); + + op.ignore("type"); + } + +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinition.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinition.java index ee16cb10df..fd2b08558f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinition.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenFilterDefinition.java @@ -161,6 +161,8 @@ public enum Kind implements JsonEnum { WordDelimiter("word_delimiter"), + SmartcnStop("smartcn_stop"), + ; private final String jsonValue; @@ -1575,7 +1577,18 @@ public ObjectBuilder wordDelimiter( return this.wordDelimiter(fn.apply(new WordDelimiterTokenFilter.Builder()).build()); } - public TokenFilterDefinition build() { + public ObjectBuilder smartcn_stop(SmartcnStopTokenFilter v) { + this._kind = Kind.IcuTokenizer; + this._value = v; + return this; + } + + public ObjectBuilder smartcn_stop( + Function> fn) { + return this.smartcn_stop(fn.apply(new SmartcnStopTokenFilter.Builder()).build()); + } + + public TokenFilterDefinition build() { _checkSingleUse(); return new TokenFilterDefinition(this); } @@ -1634,6 +1647,7 @@ protected static void setupTokenFilterDefinitionDeserializer(ObjectDeserializer< op.add(Builder::uppercase, UppercaseTokenFilter._DESERIALIZER, "uppercase"); op.add(Builder::wordDelimiterGraph, WordDelimiterGraphTokenFilter._DESERIALIZER, "word_delimiter_graph"); op.add(Builder::wordDelimiter, WordDelimiterTokenFilter._DESERIALIZER, "word_delimiter"); + op.add(Builder::smartcn_stop, SmartcnStopTokenFilter._DESERIALIZER, Kind.SmartcnStop.jsonValue()); op.setTypeProperty("type", null); diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenizerDefinition.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenizerDefinition.java index 79b541851b..2a8b2f0dde 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenizerDefinition.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/analysis/TokenizerDefinition.java @@ -93,6 +93,8 @@ public enum Kind implements JsonEnum { Whitespace("whitespace"), + SmartcnTokenizer("smartcn_tokenizer"), + ; private final String jsonValue; @@ -542,7 +544,18 @@ public ObjectBuilder whitespace( return this.whitespace(fn.apply(new WhitespaceTokenizer.Builder()).build()); } - public TokenizerDefinition build() { + public ObjectBuilder smartcn(SmartcnTokenizer v) { + this._kind = Kind.SmartcnTokenizer; + this._value = v; + return this; + } + + public ObjectBuilder smartcn( + Function> fn) { + return this.smartcn(fn.apply(new SmartcnTokenizer.Builder()).build()); + } + + public TokenizerDefinition build() { _checkSingleUse(); return new TokenizerDefinition(this); } @@ -565,6 +578,7 @@ protected static void setupTokenizerDefinitionDeserializer(ObjectDeserializer b).build(); + + String str = toJson(tokenizerDefinition); + assertEquals("{\"type\":\"smartcn_tokenizer\"}", str); + + TokenizerDefinition tokenizerDefinition2 = fromJson(str, TokenizerDefinition._DESERIALIZER); + } + + @Test + public void testSmartcn_StopFilter() { + final TokenFilterDefinition analyzer = new TokenFilterDefinition.Builder() + .smartcn_stop(b -> b) + .build(); + + String str = toJson(analyzer); + assertEquals("{\"type\":\"smartcn_stop\"}", str); + + TokenFilterDefinition analyzer2 = fromJson(str, TokenFilterDefinition._DESERIALIZER); + } + @Test + public void testCjk_Analyzer() { + final Analyzer analyzer = new Analyzer.Builder() + .cjk(b -> b + .stopwords(List.of("a", "b", "c")) + .stopwordsPath("path") + ) + .build(); + + assertTrue(analyzer.isCjk()); + + String str = toJson(analyzer); + assertEquals("{\"type\":\"cjk\",\"stopwords\":[\"a\",\"b\",\"c\"],\"stopwords_path\":\"path\"}", str); + + Analyzer analyzer2 = fromJson(str, Analyzer._DESERIALIZER); + assertTrue(analyzer2.isCjk()); + assertEquals(analyzer.cjk().stopwords(), analyzer2.cjk().stopwords()); + assertEquals(analyzer.cjk().stopwordsPath(), analyzer2.cjk().stopwordsPath()); + } }