From 334f0d99085e01c4a54a8f3d6a35e054db834e40 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Thu, 27 Jan 2022 14:04:26 -0600 Subject: [PATCH] [Remove] Setting explicit version on analysis component (#1986) Lucene 9 removes the ability to define an explicit version on an analysis component so remove the the version parameter and deprecation warning prohibiting users from explicitly setting versioned analyzers. Signed-off-by: Nicholas Walter Knize --- .../common/CompoundAnalysisTests.java | 1 - .../AbstractIndexAnalyzerProvider.java | 1 - .../analysis/AbstractTokenFilterFactory.java | 1 - .../analysis/AbstractTokenizerFactory.java | 1 - .../opensearch/index/analysis/Analysis.java | 15 --------------- .../indices/analysis/AnalysisModuleTests.java | 19 ------------------- .../org/opensearch/index/analysis/test1.json | 4 ---- .../org/opensearch/index/analysis/test1.yml | 3 --- 8 files changed, 45 deletions(-) diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CompoundAnalysisTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CompoundAnalysisTests.java index ca213034442fd..e5ce7c818f72b 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CompoundAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CompoundAnalysisTests.java @@ -81,7 +81,6 @@ public void testDictionaryDecompounder() throws Exception { hasItems("donau", "dampf", "schiff", "donaudampfschiff", "spargel", "creme", "suppe", "spargelcremesuppe") ); } - assertWarnings("Setting [version] on analysis [custom7] is deprecated, no longer used, and will be removed in a future version."); } private List analyze(Settings settings, String analyzerName, String text) throws IOException { diff --git a/server/src/main/java/org/opensearch/index/analysis/AbstractIndexAnalyzerProvider.java b/server/src/main/java/org/opensearch/index/analysis/AbstractIndexAnalyzerProvider.java index eb279a9127dc4..e1c5fd0ba3c64 100644 --- a/server/src/main/java/org/opensearch/index/analysis/AbstractIndexAnalyzerProvider.java +++ b/server/src/main/java/org/opensearch/index/analysis/AbstractIndexAnalyzerProvider.java @@ -50,7 +50,6 @@ public abstract class AbstractIndexAnalyzerProvider extends public AbstractIndexAnalyzerProvider(IndexSettings indexSettings, String name, Settings settings) { super(indexSettings); this.name = name; - Analysis.parseAndDeprecateAnalysisVersion(name, settings); } /** diff --git a/server/src/main/java/org/opensearch/index/analysis/AbstractTokenFilterFactory.java b/server/src/main/java/org/opensearch/index/analysis/AbstractTokenFilterFactory.java index 2f91c19c1b78d..fb465eb273382 100644 --- a/server/src/main/java/org/opensearch/index/analysis/AbstractTokenFilterFactory.java +++ b/server/src/main/java/org/opensearch/index/analysis/AbstractTokenFilterFactory.java @@ -43,7 +43,6 @@ public abstract class AbstractTokenFilterFactory extends AbstractIndexComponent public AbstractTokenFilterFactory(IndexSettings indexSettings, String name, Settings settings) { super(indexSettings); this.name = name; - Analysis.parseAndDeprecateAnalysisVersion(name, settings); } @Override diff --git a/server/src/main/java/org/opensearch/index/analysis/AbstractTokenizerFactory.java b/server/src/main/java/org/opensearch/index/analysis/AbstractTokenizerFactory.java index 825f8241d3e2e..9a0f4196bab16 100644 --- a/server/src/main/java/org/opensearch/index/analysis/AbstractTokenizerFactory.java +++ b/server/src/main/java/org/opensearch/index/analysis/AbstractTokenizerFactory.java @@ -41,7 +41,6 @@ public abstract class AbstractTokenizerFactory extends AbstractIndexComponent im public AbstractTokenizerFactory(IndexSettings indexSettings, Settings settings, String name) { super(indexSettings); - Analysis.parseAndDeprecateAnalysisVersion(name, settings); this.name = name; } diff --git a/server/src/main/java/org/opensearch/index/analysis/Analysis.java b/server/src/main/java/org/opensearch/index/analysis/Analysis.java index 8d780bdd4483e..90bb21cfc0a4b 100644 --- a/server/src/main/java/org/opensearch/index/analysis/Analysis.java +++ b/server/src/main/java/org/opensearch/index/analysis/Analysis.java @@ -68,7 +68,6 @@ import org.apache.lucene.analysis.th.ThaiAnalyzer; import org.apache.lucene.analysis.tr.TurkishAnalyzer; import org.opensearch.common.Strings; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -91,20 +90,6 @@ public class Analysis { - private static DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(Analysis.class); - - /** version is deprecated and will be removed; this method parses explicit version and issues a deprecation warning */ - public static void parseAndDeprecateAnalysisVersion(String name, Settings settings) { - // check for explicit version on the specific analyzer component - String sVersion = settings.get("version"); - if (sVersion != null) { - DEPRECATION_LOGGER.deprecate( - "analyzer.version", - "Setting [version] on analysis [" + name + "] is deprecated, no longer used, and will be removed in a future version." - ); - } - } - public static CharArraySet parseStemExclusion(Settings settings, CharArraySet defaultStemExclusion) { String value = settings.get("stem_exclusion"); if ("_none_".equals(value)) { diff --git a/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java b/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java index 459ac98cec955..fa927a58a2de1 100644 --- a/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java +++ b/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java @@ -39,7 +39,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.hunspell.Dictionary; -import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.store.Directory; import org.apache.lucene.store.NIOFSDirectory; @@ -92,7 +91,6 @@ import static org.hamcrest.Matchers.either; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; public class AnalysisModuleTests extends OpenSearchTestCase { private final Settings emptyNodeSettings = Settings.builder() @@ -138,28 +136,11 @@ private Settings loadFromClasspath(String path) throws IOException { public void testSimpleConfigurationJson() throws IOException { Settings settings = loadFromClasspath("/org/opensearch/index/analysis/test1.json"); testSimpleConfiguration(settings); - assertWarnings("Setting [version] on analysis [custom7] is deprecated, no longer used, and will be removed in a future version."); } public void testSimpleConfigurationYaml() throws IOException { Settings settings = loadFromClasspath("/org/opensearch/index/analysis/test1.yml"); testSimpleConfiguration(settings); - assertWarnings("Setting [version] on analysis [custom7] is deprecated, no longer used, and will be removed in a future version."); - } - - public void testVersionedAnalyzers() throws Exception { - String yaml = "/org/opensearch/index/analysis/test1.yml"; - Version version = VersionUtils.randomVersion(random()); - Settings settings2 = Settings.builder() - .loadFromStream(yaml, getClass().getResourceAsStream(yaml), false) - .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, version) - .build(); - AnalysisRegistry newRegistry = getNewRegistry(settings2); - IndexAnalyzers indexAnalyzers = getIndexAnalyzers(newRegistry, settings2); - - assertThat(indexAnalyzers.get("custom7").analyzer(), is(instanceOf(StandardAnalyzer.class))); - assertWarnings("Setting [version] on analysis [custom7] is deprecated, no longer used, and will be removed in a future version."); } private void testSimpleConfiguration(Settings settings) throws IOException { diff --git a/server/src/test/resources/org/opensearch/index/analysis/test1.json b/server/src/test/resources/org/opensearch/index/analysis/test1.json index 3cbc9f8e1ae28..fae7a516ba75a 100644 --- a/server/src/test/resources/org/opensearch/index/analysis/test1.json +++ b/server/src/test/resources/org/opensearch/index/analysis/test1.json @@ -35,10 +35,6 @@ "custom6":{ "tokenizer":"standard", "position_increment_gap": 256 - }, - "custom7":{ - "type":"standard", - "version": 3.6 } } } diff --git a/server/src/test/resources/org/opensearch/index/analysis/test1.yml b/server/src/test/resources/org/opensearch/index/analysis/test1.yml index 6b5d47128eab4..b4828003223b0 100644 --- a/server/src/test/resources/org/opensearch/index/analysis/test1.yml +++ b/server/src/test/resources/org/opensearch/index/analysis/test1.yml @@ -25,6 +25,3 @@ index : custom6 : tokenizer : standard position_increment_gap: 256 - custom7 : - type : standard - version: 3.6