Skip to content

Commit

Permalink
Revert "Removing IndexVersions.V_7_0_0 and IndexVersions.V_7_1_0"
Browse files Browse the repository at this point in the history
This reverts commit 4bc8e00.
  • Loading branch information
javanna committed Sep 20, 2024
1 parent c746906 commit c27a917
Show file tree
Hide file tree
Showing 21 changed files with 359 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void testShingleFilters() {
Settings settings = Settings.builder()
.put(
IndexMetadata.SETTING_VERSION_CREATED,
IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_8_0_0, IndexVersion.current())
IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_7_0_0, IndexVersion.current())
)
.put("path.home", createTempDir().toString())
.put("index.analysis.filter.synonyms.type", "synonym")
Expand Down Expand Up @@ -392,7 +392,7 @@ public void testPreconfiguredTokenFilters() throws IOException {
Settings settings = Settings.builder()
.put(
IndexMetadata.SETTING_VERSION_CREATED,
IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_8_0_0, IndexVersion.current())
IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_7_0_0, IndexVersion.current())
)
.put("path.home", createTempDir().toString())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.analysis.AnalysisTestsHelper;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
Expand All @@ -25,6 +26,7 @@
import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.index.IndexVersionUtils;

import java.io.IOException;
import java.io.StringReader;
Expand Down Expand Up @@ -179,26 +181,61 @@ public void testIgnoreKeywords() throws IOException {
}

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, IndexVersion.current())
.put("index.analysis.analyzer.my_analyzer.tokenizer", "standard")
.putList("index.analysis.analyzer.my_analyzer.filter", "word_delimiter_graph")
.build();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);
// Before 7.3 we don't adjust offsets
{
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.put(
IndexMetadata.SETTING_VERSION_CREATED,
IndexVersionUtils.randomVersionBetween(
random(),
IndexVersions.V_7_0_0,
IndexVersionUtils.getPreviousVersion(IndexVersions.V_7_3_0)
)
)
.put("index.analysis.analyzer.my_analyzer.tokenizer", "standard")
.putList("index.analysis.analyzer.my_analyzer.filter", "word_delimiter_graph")
.build();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);

try (
IndexAnalyzers indexAnalyzers = new AnalysisModule(
TestEnvironment.newEnvironment(settings),
Collections.singletonList(new CommonAnalysisPlugin()),
new StablePluginsRegistry()
).getAnalysisRegistry().build(IndexCreationContext.CREATE_INDEX, idxSettings)
) {

NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer");
assertNotNull(analyzer);
assertAnalyzesTo(analyzer, "h100", new String[] { "h", "100" }, new int[] { 0, 0 }, new int[] { 4, 4 });

}
}

// Afger 7.3 we do adjust offsets
{
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = Settings.builder()
.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();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);

try (
IndexAnalyzers indexAnalyzers = new AnalysisModule(
TestEnvironment.newEnvironment(settings),
Collections.singletonList(new CommonAnalysisPlugin()),
new StablePluginsRegistry()
).getAnalysisRegistry().build(IndexCreationContext.CREATE_INDEX, idxSettings)
) {
try (
IndexAnalyzers indexAnalyzers = new AnalysisModule(
TestEnvironment.newEnvironment(settings),
Collections.singletonList(new CommonAnalysisPlugin()),
new StablePluginsRegistry()
).getAnalysisRegistry().build(IndexCreationContext.CREATE_INDEX, idxSettings)
) {

NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer");
assertNotNull(analyzer);
assertAnalyzesTo(analyzer, "h100", new String[] { "h", "100" }, new int[] { 0, 1 }, new int[] { 1, 4 });
NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer");
assertNotNull(analyzer);
assertAnalyzesTo(analyzer, "h100", new String[] { "h", "100" }, new int[] { 0, 1 }, new int[] { 1, 4 });

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.geometry.Geometry;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.mapper.AbstractShapeGeometryFieldMapper;
import org.elasticsearch.index.mapper.DocumentParserContext;
Expand Down Expand Up @@ -232,7 +233,9 @@ public Builder(String name, IndexVersion version, boolean ignoreMalformedByDefau
});

// Set up serialization
this.strategy.alwaysSerialize();
if (version.onOrAfter(IndexVersions.V_7_0_0)) {
this.strategy.alwaysSerialize();
}
// serialize treeLevels if treeLevels is configured, OR if defaults are requested and precision is not configured
treeLevels.setSerializerCheck((id, ic, v) -> ic || (id && precision.get() == null));
// serialize precision if precision is configured, OR if defaults are requested and treeLevels is not configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public class TransportGetFeatureUpgradeStatusAction extends TransportMasterNodeA
*/
@UpdateForV9
public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_7_0_0;
@UpdateForV9
// TODO lucene 10 upgrade, we increased this to IndexVersions.V_8_0_0, not sure if that was premature. Check with ie. core/infra
public static final IndexVersion NO_UPGRADE_REQUIRED_INDEX_VERSION = IndexVersions.V_8_0_0;
public static final IndexVersion NO_UPGRADE_REQUIRED_INDEX_VERSION = IndexVersions.V_7_0_0;

private final SystemIndices systemIndices;
PersistentTasksService persistentTasksService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1629,13 +1629,21 @@ static void prepareResizeIndexSettings(
* the less default split operations are supported
*/
public static int calculateNumRoutingShards(int numShards, IndexVersion indexVersionCreated) {
// We use as a default number of routing shards the higher number that can be expressed
// as {@code numShards * 2^x`} that is less than or equal to the maximum number of shards: 1024.
int log2MaxNumShards = 10; // logBase2(1024)
int log2NumShards = 32 - Integer.numberOfLeadingZeros(numShards - 1); // ceil(logBase2(numShards))
int numSplits = log2MaxNumShards - log2NumShards;
numSplits = Math.max(1, numSplits); // Ensure the index can be split at least once
return numShards * 1 << numSplits;
if (indexVersionCreated.onOrAfter(IndexVersions.V_7_0_0)) {
// only select this automatically for indices that are created on or after 7.0 this will prevent this new behaviour
// until we have a fully upgraded cluster. Additionally it will make integrating testing easier since mixed clusters
// will always have the behavior of the min node in the cluster.
//
// We use as a default number of routing shards the higher number that can be expressed
// as {@code numShards * 2^x`} that is less than or equal to the maximum number of shards: 1024.
int log2MaxNumShards = 10; // logBase2(1024)
int log2NumShards = 32 - Integer.numberOfLeadingZeros(numShards - 1); // ceil(logBase2(numShards))
int numSplits = log2MaxNumShards - log2NumShards;
numSplits = Math.max(1, numSplits); // Ensure the index can be split at least once
return numShards * 1 << numSplits;
} else {
return numShards;
}
}

public static void validateTranslogRetentionSettings(Settings indexSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.core.UpdateForV9;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -438,8 +437,6 @@ public synchronized <T> void initializeAndWatch(Setting<T> setting, Consumer<T>
addSettingsUpdateConsumer(setting, consumer);
}

@UpdateForV9
// do we need to rename / rework this method for v9?
protected void validateDeprecatedAndRemovedSettingV7(Settings settings, Setting<?> setting) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ protected void validateDeprecatedAndRemovedSettingV7(Settings settings, Setting<
// error out on those validations, we will check with the creation version present at index
// creation time, as well as on index update settings.
if (indexVersion.equals(IndexVersions.ZERO) == false
// TODO lucene 10 upgrade, check if we need to change anything for pre8 indices
// old: && (indexVersion.before(IndexVersions.V_7_0_0) || indexVersion.onOrAfter(IndexVersions.V_8_0_0))) {
&& indexVersion.onOrAfter(IndexVersions.V_8_0_0)) {
&& (indexVersion.before(IndexVersions.V_7_0_0) || indexVersion.onOrAfter(IndexVersions.V_8_0_0))) {
throw new IllegalArgumentException("unknown setting [" + setting.getKey() + "]");
}
}
Expand Down
20 changes: 20 additions & 0 deletions server/src/main/java/org/elasticsearch/index/IndexVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ private static Version parseUnchecked(String version) {

@UpdateForV9 // remove the index versions with which v9 will not need to interact
public static final IndexVersion ZERO = def(0, Version.LATEST);
public static final IndexVersion V_7_0_0 = def(7_00_00_99, parseUnchecked("8.0.0"));
public static final IndexVersion V_7_1_0 = def(7_01_00_99, parseUnchecked("8.0.0"));
public static final IndexVersion V_7_2_0 = def(7_02_00_99, parseUnchecked("8.0.0"));
public static final IndexVersion V_7_2_1 = def(7_02_01_99, parseUnchecked("8.0.0"));
public static final IndexVersion V_7_3_0 = def(7_03_00_99, parseUnchecked("8.1.0"));
public static final IndexVersion V_7_4_0 = def(7_04_00_99, parseUnchecked("8.2.0"));
public static final IndexVersion V_7_5_0 = def(7_05_00_99, parseUnchecked("8.3.0"));
public static final IndexVersion V_7_5_2 = def(7_05_02_99, parseUnchecked("8.3.0"));
public static final IndexVersion V_7_6_0 = def(7_06_00_99, parseUnchecked("8.4.0"));
public static final IndexVersion V_7_7_0 = def(7_07_00_99, parseUnchecked("8.5.1"));
public static final IndexVersion V_7_8_0 = def(7_08_00_99, parseUnchecked("8.5.1"));
public static final IndexVersion V_7_9_0 = def(7_09_00_99, parseUnchecked("8.6.0"));
public static final IndexVersion V_7_10_0 = def(7_10_00_99, parseUnchecked("8.7.0"));
public static final IndexVersion V_7_11_0 = def(7_11_00_99, parseUnchecked("8.7.0"));
public static final IndexVersion V_7_12_0 = def(7_12_00_99, parseUnchecked("8.8.0"));
public static final IndexVersion V_7_13_0 = def(7_13_00_99, parseUnchecked("8.8.2"));
public static final IndexVersion V_7_14_0 = def(7_14_00_99, parseUnchecked("8.9.0"));
public static final IndexVersion V_7_15_0 = def(7_15_00_99, parseUnchecked("8.9.0"));
public static final IndexVersion V_7_16_0 = def(7_16_00_99, parseUnchecked("8.10.1"));
public static final IndexVersion V_7_17_0 = def(7_17_00_99, parseUnchecked("8.11.1"));
public static final IndexVersion V_8_0_0 = def(8_00_00_99, Version.LUCENE_9_0_0);
public static final IndexVersion V_8_1_0 = def(8_01_00_99, Version.LUCENE_9_0_0);
public static final IndexVersion V_8_2_0 = def(8_02_00_99, Version.LUCENE_9_1_0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Map<String, RuntimeField.Parser> getRuntimeFieldParsers() {
public Map<String, MetadataFieldMapper.TypeParser> getMetadataMapperParsers(IndexVersion indexCreatedVersion) {
if (indexCreatedVersion.onOrAfter(IndexVersions.V_8_0_0)) {
return metadataMapperParsers;
} else if (indexCreatedVersion.onOrAfter(IndexVersion.fromId(7000099))) {
} else if (indexCreatedVersion.onOrAfter(IndexVersions.V_7_0_0)) {
return metadataMapperParsers7x;
} else if (indexCreatedVersion.onOrAfter(IndexVersion.fromId(6000099))) {
return metadataMapperParsers6x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
import org.apache.lucene.search.similarities.NormalizationH2;
import org.apache.lucene.search.similarities.NormalizationH3;
import org.apache.lucene.search.similarities.NormalizationZ;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.lucene.similarity.LegacyBM25Similarity;

import java.util.Arrays;
Expand Down Expand Up @@ -100,9 +102,23 @@ private static BasicModel parseBasicModel(IndexVersion indexCreatedVersion, Sett
if (model == null) {
String replacement = LEGACY_BASIC_MODELS.get(basicModel);
if (replacement != null) {
throw new IllegalArgumentException(
"Basic model [" + basicModel + "] isn't supported anymore, " + "please use another model."
);
if (indexCreatedVersion.onOrAfter(IndexVersions.V_7_0_0)) {
throw new IllegalArgumentException(
"Basic model [" + basicModel + "] isn't supported anymore, " + "please use another model."
);
} else {
deprecationLogger.warn(
DeprecationCategory.INDICES,
basicModel + "_similarity_model_replaced",
"Basic model ["
+ basicModel
+ "] isn't supported anymore and has arbitrarily been replaced with ["
+ replacement
+ "]."
);
model = BASIC_MODELS.get(replacement);
assert model != null;
}
}
}

Expand All @@ -125,9 +141,23 @@ private static AfterEffect parseAfterEffect(IndexVersion indexCreatedVersion, Se
if (effect == null) {
String replacement = LEGACY_AFTER_EFFECTS.get(afterEffect);
if (replacement != null) {
throw new IllegalArgumentException(
"After effect [" + afterEffect + "] isn't supported anymore, please use another effect."
);
if (indexCreatedVersion.onOrAfter(IndexVersions.V_7_0_0)) {
throw new IllegalArgumentException(
"After effect [" + afterEffect + "] isn't supported anymore, please use another effect."
);
} else {
deprecationLogger.warn(
DeprecationCategory.INDICES,
afterEffect + "_after_effect_replaced",
"After effect ["
+ afterEffect
+ "] isn't supported anymore and has arbitrarily been replaced with ["
+ replacement
+ "]."
);
effect = AFTER_EFFECTS.get(replacement);
assert effect != null;
}
}
}

Expand Down Expand Up @@ -211,7 +241,15 @@ static void assertSettingsIsSubsetOf(String type, IndexVersion version, Settings
unknownSettings.removeAll(Arrays.asList(supportedSettings));
unknownSettings.remove("type"); // used to figure out which sim this is
if (unknownSettings.isEmpty() == false) {
throw new IllegalArgumentException("Unknown settings for similarity of type [" + type + "]: " + unknownSettings);
if (version.onOrAfter(IndexVersions.V_7_0_0)) {
throw new IllegalArgumentException("Unknown settings for similarity of type [" + type + "]: " + unknownSettings);
} else {
deprecationLogger.warn(
DeprecationCategory.INDICES,
"unknown_similarity_setting",
"Unknown settings for similarity of type [" + type + "]: " + unknownSettings
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static NamedRegistry<AnalysisProvider<TokenFilterFactory>> setupTokenFil
tokenFilters.register("standard", new AnalysisProvider<TokenFilterFactory>() {
@Override
public TokenFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
if (indexSettings.getIndexVersionCreated().before(IndexVersions.V_8_0_0)) {
if (indexSettings.getIndexVersionCreated().before(IndexVersions.V_7_0_0)) {
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"standard_deprecation",
Expand Down
Loading

0 comments on commit c27a917

Please sign in to comment.