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

[Remove] Setting explicit version on analysis component #1986

Merged
merged 1 commit into from
Jan 27, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> analyze(Settings settings, String analyzerName, String text) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public abstract class AbstractIndexAnalyzerProvider<T extends Analyzer> extends
public AbstractIndexAnalyzerProvider(IndexSettings indexSettings, String name, Settings settings) {
super(indexSettings);
this.name = name;
Analysis.parseAndDeprecateAnalysisVersion(name, settings);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.LiveIndexWriterConfig;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.lucene.index.LogDocMergePolicy;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.NoMergePolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
"custom6":{
"tokenizer":"standard",
"position_increment_gap": 256
},
"custom7":{
"type":"standard",
"version": 3.6
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ index :
custom6 :
tokenizer : standard
position_increment_gap: 256
custom7 :
type : standard
version: 3.6