Skip to content

Commit

Permalink
Bulk migration of Version.CURRENT for index created to IndexVersion.c…
Browse files Browse the repository at this point in the history
…urrent() (elastic#98490)
  • Loading branch information
thecoop authored Aug 15, 2023
1 parent 0df27ce commit a830787
Show file tree
Hide file tree
Showing 86 changed files with 367 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.Version;
import org.elasticsearch.aggregations.AggregationsPlugin;
import org.elasticsearch.aggregations.pipeline.DerivativePipelineAggregationBuilder;
import org.elasticsearch.cluster.metadata.IndexMetadata;
Expand All @@ -33,6 +32,7 @@
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.core.Strings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.mapper.BooleanFieldMapper;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.IpFieldMapper;
Expand Down Expand Up @@ -1008,7 +1008,7 @@ protected IndexSettings createIndexSettings() {
final Settings nodeSettings = Settings.builder().put("search.max_buckets", 25000).build();
return new IndexSettings(
IndexMetadata.builder("_index")
.settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT))
.settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()))
.numberOfShards(1)
.numberOfReplicas(0)
.creationDate(System.currentTimeMillis())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.MyFilterTokenFilterFactory;
import org.elasticsearch.index.analysis.TokenFilterFactory;
Expand Down Expand Up @@ -94,7 +94,7 @@ private Settings getJsonSettings() throws IOException {
String json = "/org/elasticsearch/analysis/common/test1.json";
return Settings.builder()
.loadFromStream(json, getClass().getResourceAsStream(json), false)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.build();
}
Expand All @@ -103,7 +103,7 @@ private Settings getYamlSettings() throws IOException {
String yaml = "/org/elasticsearch/analysis/common/test1.yml";
return Settings.builder()
.loadFromStream(yaml, getClass().getResourceAsStream(yaml), false)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

package org.elasticsearch.analysis.common;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.indices.analysis.AnalysisModule;
Expand All @@ -30,7 +30,7 @@ public class MultiplexerTokenFilterTests extends ESTokenStreamTestCase {
public void testMultiplexingFilter() throws IOException {
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("index.analysis.filter.t.type", "truncate")
.put("index.analysis.filter.t.length", "2")
.put("index.analysis.filter.multiplexFilter.type", "multiplexer")
Expand Down Expand Up @@ -64,7 +64,7 @@ public void testMultiplexingNoOriginal() throws IOException {

Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("index.analysis.filter.t.type", "truncate")
.put("index.analysis.filter.t.length", "2")
.put("index.analysis.filter.multiplexFilter.type", "multiplexer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

package org.elasticsearch.analysis.common;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.test.ESTokenStreamTestCase;
Expand All @@ -27,7 +27,7 @@ public void testPatternCaptureTokenFilter() throws Exception {
Settings settings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.loadFromStream(json, getClass().getResourceAsStream(json), false)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.build();

IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.elasticsearch.analysis.common;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand All @@ -21,6 +20,7 @@
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.indices.analysis.AnalysisModule;
Expand All @@ -41,7 +41,7 @@ public class PredicateTokenScriptFilterTests extends ESTokenStreamTestCase {
public void testSimpleFilter() throws IOException {
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("index.analysis.filter.f.type", "predicate_token_filter")
.put("index.analysis.filter.f.script.source", "my_script")
.put("index.analysis.analyzer.myAnalyzer.type", "custom")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.elasticsearch.analysis.common;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand All @@ -21,6 +20,7 @@
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.indices.analysis.AnalysisModule;
Expand All @@ -40,7 +40,7 @@ public class ScriptedConditionTokenFilterTests extends ESTokenStreamTestCase {
public void testSimpleCondition() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("index.analysis.filter.cond.type", "condition")
.put("index.analysis.filter.cond.script.source", "token.getPosition() > 1")
.putList("index.analysis.filter.cond.filter", "uppercase")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

package org.elasticsearch.analysis.common;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.test.ESTokenStreamTestCase;
Expand All @@ -26,7 +26,7 @@ public void testDefaultsCompoundAnalysis() throws Exception {
Settings settings = Settings.builder()
.loadFromStream(json, getClass().getResourceAsStream(json), false)
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.build();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
IndexAnalyzers indexAnalyzers = createTestAnalysis(idxSettings, settings, new CommonAnalysisPlugin()).indexAnalyzers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.PreConfiguredTokenFilter;
import org.elasticsearch.index.analysis.TokenFilterFactory;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void testSynonymsAnalysis() throws IOException {
Settings settings = Settings.builder()
.loadFromStream(json, getClass().getResourceAsStream(json), false)
.put(Environment.PATH_HOME_SETTING.getKey(), home)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.build();

IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
Expand All @@ -78,7 +79,7 @@ public void testSynonymsAnalysis() throws IOException {

public void testSynonymWordDeleteByAnalyzer() throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.my_synonym.type", "synonym")
.putList("index.analysis.filter.my_synonym.synonyms", "kimchy => shay", "dude => elasticsearch", "abides => man!")
Expand Down Expand Up @@ -106,7 +107,7 @@ public void testSynonymWordDeleteByAnalyzerFromFile() throws IOException {
Files.copy(synonyms, config.resolve("synonyms.txt"));

Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", home)
.put("index.analysis.filter.my_synonym.type", "synonym")
.put("index.analysis.filter.my_synonym.synonyms_path", "synonyms.txt")
Expand All @@ -127,7 +128,7 @@ public void testSynonymWordDeleteByAnalyzerFromFile() throws IOException {

public void testExpandSynonymWordDeleteByAnalyzer() throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.synonym_expand.type", "synonym")
.putList("index.analysis.filter.synonym_expand.synonyms", "kimchy, shay", "dude, elasticsearch", "abides, man!")
Expand All @@ -149,7 +150,7 @@ public void testExpandSynonymWordDeleteByAnalyzer() throws IOException {

public void testSynonymsWrappedByMultiplexer() throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.synonyms.type", "synonym")
.putList("index.analysis.filter.synonyms.synonyms", "programmer, developer")
Expand All @@ -173,7 +174,7 @@ public void testSynonymsWrappedByMultiplexer() throws IOException {

public void testAsciiFoldingFilterForSynonyms() throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.synonyms.type", "synonym")
.putList("index.analysis.filter.synonyms.synonyms", "hoj, height")
Expand All @@ -193,7 +194,7 @@ public void testAsciiFoldingFilterForSynonyms() throws IOException {

public void testPreconfigured() throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.synonyms.type", "synonym")
.putList("index.analysis.filter.synonyms.synonyms", "würst, sausage")
Expand All @@ -213,7 +214,7 @@ public void testPreconfigured() throws IOException {

public void testChainedSynonymFilters() throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.synonyms1.type", "synonym")
.putList("index.analysis.filter.synonyms1.synonyms", "term1, term2")
Expand Down Expand Up @@ -255,7 +256,7 @@ public void testShingleFilters() {
public void testTokenFiltersBypassSynonymAnalysis() throws IOException {

Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("path.home", createTempDir().toString())
.putList("word_list", "a")
.put("hyphenation_patterns_path", "foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import com.carrotsearch.randomizedtesting.generators.RandomStrings;

import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;

Expand All @@ -28,7 +28,7 @@
public class WhitespaceTokenizerFactoryTests extends ESTestCase {

public void testSimpleWhiteSpaceTokenizer() throws IOException {
final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build();
final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build();
IndexSettings indexProperties = IndexSettingsModule.newIndexSettings(new Index("test", "_na_"), indexSettings);
WhitespaceTokenizer tokenizer = (WhitespaceTokenizer) new WhitespaceTokenizerFactory(
indexProperties,
Expand All @@ -44,7 +44,7 @@ public void testSimpleWhiteSpaceTokenizer() throws IOException {
}

public void testMaxTokenLength() throws IOException {
final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build();
final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build();
IndexSettings indexProperties = IndexSettingsModule.newIndexSettings(new Index("test", "_na_"), indexSettings);
final Settings settings = Settings.builder().put(WhitespaceTokenizerFactory.MAX_TOKEN_LENGTH, 2).build();
WhitespaceTokenizer tokenizer = (WhitespaceTokenizer) new WhitespaceTokenizerFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.AnalysisTestsHelper;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
Expand Down Expand Up @@ -211,7 +212,7 @@ public void testPreconfiguredFilter() throws IOException {
{
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put("index.analysis.analyzer.my_analyzer.tokenizer", "standard")
.putList("index.analysis.analyzer.my_analyzer.filter", "word_delimiter_graph")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ public void testIlmManagedIndicesAreSkipped() {
builder,
dataStreamName,
numBackingIndices,
Settings.builder().put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy").put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT),
Settings.builder()
.put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy")
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()),
DataStreamLifecycle.newBuilder().dataRetention(0).build(),
now
);
Expand All @@ -234,7 +236,9 @@ public void testDataStreamsWithoutLifecycleAreSkipped() {
builder,
dataStreamName,
numBackingIndices,
Settings.builder().put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy").put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT),
Settings.builder()
.put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy")
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()),
null,
now
);
Expand All @@ -253,7 +257,7 @@ public void testDeletedIndicesAreRemovedFromTheErrorStore() throws IOException {
builder,
dataStreamName,
numBackingIndices,
Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT),
Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()),
new DataStreamLifecycle(),
now
);
Expand Down
Loading

0 comments on commit a830787

Please sign in to comment.