Skip to content

Commit

Permalink
Re-introduce index.mapper.dynamic setting (elastic#120484)
Browse files Browse the repository at this point in the history
This change re-introduces the deprecated index.mapper.dynamic setting that
was already removed via elastic#113000. With the new read-only support for N-2 indices
we can still have this setting in indices created with version 7, so it's better to have
the deprecated settings definition around.
  • Loading branch information
cbuescher authored Jan 21, 2025
1 parent 6db7984 commit 0488b03
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING,
MapperService.INDEX_MAPPING_DIMENSION_FIELDS_LIMIT_SETTING,
MapperService.INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING,
MapperService.INDEX_MAPPER_DYNAMIC_SETTING,
BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING,
IndexModule.INDEX_STORE_TYPE_SETTING,
IndexModule.INDEX_STORE_PRE_LOAD_SETTING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public enum Property {
* Indicates that this index-level setting was deprecated in {@link Version#V_7_17_0} and is
* forbidden in indices created from {@link Version#V_8_0_0} onwards.
*/
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // introduce IndexSettingDeprecatedInV8AndRemovedInV9 to replace this constant
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // introduce IndexSettingDeprecatedInV8AndRemovedInV10
// note we still need v7 settings in v9 because we support reading from N-2 indices now
IndexSettingDeprecatedInV7AndRemovedInV8,

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ public boolean isAutoUpdate() {
Property.Dynamic,
Property.IndexScope
);
/**
* Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use.
*/
@Deprecated
public static final Setting<Boolean> INDEX_MAPPER_DYNAMIC_SETTING = Setting.boolSetting(
"index.mapper.dynamic",
true,
Property.Dynamic,
Property.IndexScope,
Property.IndexSettingDeprecatedInV7AndRemovedInV8
);

private final IndexAnalyzers indexAnalyzers;
private final MappingParser mappingParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
package org.elasticsearch.index;

import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.IndexMetadataVerifier;
import org.elasticsearch.common.settings.AbstractScopedSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.mapper.MapperMetrics;
import org.elasticsearch.index.mapper.MapperRegistry;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.plugins.MapperPlugin;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.hamcrest.Matchers;
Expand All @@ -39,6 +43,7 @@
import static org.elasticsearch.index.IndexSettings.STATELESS_MIN_NON_FAST_REFRESH_INTERVAL;
import static org.elasticsearch.index.IndexSettings.TIME_SERIES_END_TIME;
import static org.elasticsearch.index.IndexSettings.TIME_SERIES_START_TIME;
import static org.elasticsearch.index.mapper.MapperService.INDEX_MAPPER_DYNAMIC_SETTING;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.StringContains.containsString;
Expand Down Expand Up @@ -839,6 +844,35 @@ public void testTimeSeriesTimeBoundary() {
assertThat(e.getMessage(), Matchers.containsString("index.time_series.end_time must be larger than index.time_series.start_time"));
}

public void testIndexMapperDynamic() {
Settings settings = Settings.builder().put(INDEX_MAPPER_DYNAMIC_SETTING.getKey(), randomBoolean()).build();

INDEX_MAPPER_DYNAMIC_SETTING.get(settings);
assertWarnings(
"[index.mapper.dynamic] setting was deprecated in the previous Elasticsearch release and is removed in this release."
);

IndexMetadata idxMetaData = newIndexMeta("test", settings);
IndexMetadataVerifier indexMetadataVerifier = new IndexMetadataVerifier(
Settings.EMPTY,
null,
xContentRegistry(),
new MapperRegistry(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), MapperPlugin.NOOP_FIELD_FILTER),
IndexScopedSettings.DEFAULT_SCOPED_SETTINGS,
null,
MapperMetrics.NOOP
);
IndexMetadata verifiedMetaData = indexMetadataVerifier.verifyIndexMetadata(
idxMetaData,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE
);
assertEquals(idxMetaData, verifiedMetaData);
assertWarnings(
"[index.mapper.dynamic] setting was deprecated in the previous Elasticsearch release and is removed in this release."
);
}

public void testSame() {
final var indexSettingKey = "index.example.setting";
final var archivedSettingKey = "archived.example.setting";
Expand Down

0 comments on commit 0488b03

Please sign in to comment.