Skip to content

Commit fe7818a

Browse files
authored
Deprecate _source.mode in mappings (#117172)
Re-introduce #116689
1 parent 312f831 commit fe7818a

File tree

23 files changed

+162
-134
lines changed

23 files changed

+162
-134
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/RestCompatTestTransformTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void skipTest(String fullTestName, String reason) {
137137
// However, the folder can be arbitrarily nest so, a == a1/a2/a3, and the test name can include forward slashes, so c == c1/c2/c3
138138
// So we also need to support a1/a2/a3/b/c1/c2/c3
139139

140-
String[] testParts = fullTestName.split("/");
140+
String[] testParts = fullTestName.split("/", 3);
141141
if (testParts.length < 3) {
142142
throw new IllegalArgumentException(
143143
"To skip tests, all 3 parts [folder/file/test name] must be defined. found [" + fullTestName + "]"

docs/changelog/116689.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pr: 116689
2+
summary: Deprecate `_source.mode` in mappings
3+
area: Mapping
4+
type: deprecation
5+
issues: []
6+
deprecation:
7+
title: Deprecate `_source.mode` in mappings
8+
area: Mapping
9+
details: Configuring `_source.mode` in mappings is deprecated and will be removed in future versions. Use `index.mapping.source.mode` index setting instead.
10+
impact: Use `index.mapping.source.mode` index setting instead

qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeFullClusterRestartIT.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.elasticsearch.common.network.InetAddresses;
1818
import org.elasticsearch.common.time.DateFormatter;
1919
import org.elasticsearch.common.time.FormatNames;
20-
import org.elasticsearch.test.MapMatcher;
2120
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2221
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2322
import org.hamcrest.Matcher;
@@ -30,9 +29,6 @@
3029
import java.util.Map;
3130
import java.util.function.Supplier;
3231

33-
import static org.elasticsearch.test.MapMatcher.assertMap;
34-
import static org.elasticsearch.test.MapMatcher.matchesMap;
35-
3632
public class LogsIndexModeFullClusterRestartIT extends ParameterizedFullClusterRestartTestCase {
3733

3834
@ClassRule
@@ -169,22 +165,16 @@ public void testLogsIndexing() throws IOException {
169165
assertOK(bulkIndexResponse);
170166
assertThat(entityAsMap(bulkIndexResponse).get("errors"), Matchers.is(false));
171167

172-
assertIndexMappingsAndSettings(0, Matchers.nullValue(), matchesMap().extraOk());
173-
assertIndexMappingsAndSettings(
174-
1,
175-
Matchers.equalTo("logsdb"),
176-
matchesMap().extraOk().entry("_source", Map.of("mode", "synthetic"))
177-
);
168+
assertIndexSettings(0, Matchers.nullValue());
169+
assertIndexSettings(1, Matchers.equalTo("logsdb"));
178170
}
179171
}
180172

181-
private void assertIndexMappingsAndSettings(int backingIndex, final Matcher<Object> indexModeMatcher, final MapMatcher mappingsMatcher)
182-
throws IOException {
173+
private void assertIndexSettings(int backingIndex, final Matcher<Object> indexModeMatcher) throws IOException {
183174
assertThat(
184175
getSettings(client(), getWriteBackingIndex(client(), "logs-apache-production", backingIndex)).get("index.mode"),
185176
indexModeMatcher
186177
);
187-
assertMap(getIndexMappingAsMap(getWriteBackingIndex(client(), "logs-apache-production", backingIndex)), mappingsMatcher);
188178
}
189179

190180
private static Request createDataStream(final String dataStreamName) {

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeRollingUpgradeIT.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.elasticsearch.common.network.InetAddresses;
1818
import org.elasticsearch.common.time.DateFormatter;
1919
import org.elasticsearch.common.time.FormatNames;
20-
import org.elasticsearch.test.MapMatcher;
2120
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2221
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2322
import org.hamcrest.Matcher;
@@ -30,9 +29,6 @@
3029
import java.util.Map;
3130
import java.util.function.Supplier;
3231

33-
import static org.elasticsearch.test.MapMatcher.assertMap;
34-
import static org.elasticsearch.test.MapMatcher.matchesMap;
35-
3632
public class LogsIndexModeRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
3733

3834
@ClassRule()
@@ -160,14 +156,10 @@ public void testLogsIndexing() throws IOException {
160156
assertOK(bulkIndexResponse);
161157
assertThat(entityAsMap(bulkIndexResponse).get("errors"), Matchers.is(false));
162158

163-
assertIndexMappingsAndSettings(0, Matchers.nullValue(), matchesMap().extraOk());
164-
assertIndexMappingsAndSettings(1, Matchers.nullValue(), matchesMap().extraOk());
165-
assertIndexMappingsAndSettings(2, Matchers.nullValue(), matchesMap().extraOk());
166-
assertIndexMappingsAndSettings(
167-
3,
168-
Matchers.equalTo("logsdb"),
169-
matchesMap().extraOk().entry("_source", Map.of("mode", "synthetic"))
170-
);
159+
assertIndexSettings(0, Matchers.nullValue());
160+
assertIndexSettings(1, Matchers.nullValue());
161+
assertIndexSettings(2, Matchers.nullValue());
162+
assertIndexSettings(3, Matchers.equalTo("logsdb"));
171163
}
172164
}
173165

@@ -183,13 +175,11 @@ static void enableLogsdbByDefault() throws IOException {
183175
assertOK(client().performRequest(request));
184176
}
185177

186-
private void assertIndexMappingsAndSettings(int backingIndex, final Matcher<Object> indexModeMatcher, final MapMatcher mappingsMatcher)
187-
throws IOException {
178+
private void assertIndexSettings(int backingIndex, final Matcher<Object> indexModeMatcher) throws IOException {
188179
assertThat(
189180
getSettings(client(), getWriteBackingIndex(client(), "logs-apache-production", backingIndex)).get("index.mode"),
190181
indexModeMatcher
191182
);
192-
assertMap(getIndexMappingAsMap(getWriteBackingIndex(client(), "logs-apache-production", backingIndex)), mappingsMatcher);
193183
}
194184

195185
private static Request createDataStream(final String dataStreamName) {

rest-api-spec/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ tasks.named("yamlRestCompatTestTransform").configure ({ task ->
6060
task.skipTest("cat.aliases/10_basic/Deprecated local parameter", "CAT APIs not covered by compatibility policy")
6161
task.skipTest("cat.shards/10_basic/Help", "sync_id is removed in 9.0")
6262
task.skipTest("search/500_date_range/from, to, include_lower, include_upper deprecated", "deprecated parameters are removed in 9.0")
63+
task.skipTest("tsdb/20_mapping/stored source is supported", "no longer serialize source_mode")
64+
task.skipTest("tsdb/20_mapping/Synthetic source", "no longer serialize source_mode")
65+
task.skipTest("logsdb/10_settings/create logs index", "no longer serialize source_mode")
66+
task.skipTest("logsdb/20_source_mapping/stored _source mode is supported", "no longer serialize source_mode")
67+
task.skipTest("logsdb/20_source_mapping/include/exclude is supported with stored _source", "no longer serialize source_mode")
68+
task.skipTest("logsdb/20_source_mapping/synthetic _source is default", "no longer serialize source_mode")
6369
})

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/logsdb/10_settings.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ create logs index:
7676
- is_true: test
7777
- match: { test.settings.index.mode: "logsdb" }
7878

79-
- do:
80-
indices.get_mapping:
81-
index: test
82-
- match: { test.mappings._source.mode: synthetic }
83-
8479
---
8580
using default timestamp field mapping:
8681
- requires:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/logsdb/20_source_mapping.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ synthetic _source is default:
1313
index:
1414
mode: logsdb
1515
- do:
16-
indices.get:
16+
indices.get_settings:
1717
index: test-default-source
18-
19-
- match: { test-default-source.mappings._source.mode: "synthetic" }
18+
- match: { test-default-source.settings.index.mode: logsdb }
19+
- match: { test-default-source.settings.index.mapping.source.mode: null }
2020

2121
---
2222
stored _source mode is supported:
@@ -28,11 +28,12 @@ stored _source mode is supported:
2828
index:
2929
mode: logsdb
3030
mapping.source.mode: stored
31+
3132
- do:
32-
indices.get:
33+
indices.get_settings:
3334
index: test-stored-source
34-
35-
- match: { test-stored-source.mappings._source.mode: "stored" }
35+
- match: { test-stored-source.settings.index.mode: logsdb }
36+
- match: { test-stored-source.settings.index.mapping.source.mode: stored }
3637

3738
---
3839
disabled _source is not supported:
@@ -110,7 +111,6 @@ include/exclude is supported with stored _source:
110111
indices.get:
111112
index: test-includes
112113

113-
- match: { test-includes.mappings._source.mode: "stored" }
114114
- match: { test-includes.mappings._source.includes: ["a"] }
115115

116116
- do:
@@ -129,5 +129,4 @@ include/exclude is supported with stored _source:
129129
indices.get:
130130
index: test-excludes
131131

132-
- match: { test-excludes.mappings._source.mode: "stored" }
133132
- match: { test-excludes.mappings._source.excludes: ["b"] }

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/20_mapping.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,6 @@ nested fields:
450450
type: long
451451
time_series_metric: gauge
452452

453-
- do:
454-
indices.get_mapping: {}
455-
456-
- match: {tsdb-synthetic.mappings._source.mode: synthetic}
457-
458453
---
459454
stored source is supported:
460455
- requires:
@@ -486,12 +481,6 @@ stored source is supported:
486481
type: keyword
487482
time_series_dimension: true
488483

489-
- do:
490-
indices.get:
491-
index: tsdb_index
492-
493-
- match: { tsdb_index.mappings._source.mode: "stored" }
494-
495484
---
496485
disabled source is not supported:
497486
- requires:

server/src/main/java/org/elasticsearch/index/IndexSettingProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.cluster.metadata.IndexMetadata;
1313
import org.elasticsearch.cluster.metadata.Metadata;
14+
import org.elasticsearch.cluster.service.ClusterService;
1415
import org.elasticsearch.common.compress.CompressedXContent;
1516
import org.elasticsearch.common.settings.Settings;
1617
import org.elasticsearch.core.CheckedFunction;
@@ -54,7 +55,7 @@ Settings getAdditionalIndexSettings(
5455
/**
5556
* Infrastructure class that holds services that can be used by {@link IndexSettingProvider} instances.
5657
*/
57-
record Parameters(CheckedFunction<IndexMetadata, MapperService, IOException> mapperServiceFactory) {
58+
record Parameters(ClusterService clusterService, CheckedFunction<IndexMetadata, MapperService, IOException> mapperServiceFactory) {
5859

5960
}
6061

server/src/main/java/org/elasticsearch/index/IndexVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ private static Version parseUnchecked(String version) {
134134
public static final IndexVersion UPGRADE_TO_LUCENE_10_0_0 = def(9_000_00_0, Version.LUCENE_10_0_0);
135135
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT = def(9_001_00_0, Version.LUCENE_10_0_0);
136136
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID = def(9_002_00_0, Version.LUCENE_10_0_0);
137+
public static final IndexVersion DEPRECATE_SOURCE_MODE_MAPPER = def(9_003_00_0, Version.LUCENE_10_0_0);
137138
/*
138139
* STOP! READ THIS FIRST! No, really,
139140
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

0 commit comments

Comments
 (0)