Skip to content

Commit ac06a84

Browse files
authored
Revert "Deprecate _source.mode in mappings (#116689)" (#117150)
This reverts commit 0d7b90e, because of bwc testing failures.
1 parent 9854fdc commit ac06a84

File tree

23 files changed

+134
-162
lines changed

23 files changed

+134
-162
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("/", 3);
140+
String[] testParts = fullTestName.split("/");
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: 0 additions & 10 deletions
This file was deleted.

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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;
2021
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2122
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2223
import org.hamcrest.Matcher;
@@ -29,6 +30,9 @@
2930
import java.util.Map;
3031
import java.util.function.Supplier;
3132

33+
import static org.elasticsearch.test.MapMatcher.assertMap;
34+
import static org.elasticsearch.test.MapMatcher.matchesMap;
35+
3236
public class LogsIndexModeFullClusterRestartIT extends ParameterizedFullClusterRestartTestCase {
3337

3438
@ClassRule
@@ -165,16 +169,22 @@ public void testLogsIndexing() throws IOException {
165169
assertOK(bulkIndexResponse);
166170
assertThat(entityAsMap(bulkIndexResponse).get("errors"), Matchers.is(false));
167171

168-
assertIndexSettings(0, Matchers.nullValue());
169-
assertIndexSettings(1, Matchers.equalTo("logsdb"));
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+
);
170178
}
171179
}
172180

173-
private void assertIndexSettings(int backingIndex, final Matcher<Object> indexModeMatcher) throws IOException {
181+
private void assertIndexMappingsAndSettings(int backingIndex, final Matcher<Object> indexModeMatcher, final MapMatcher mappingsMatcher)
182+
throws IOException {
174183
assertThat(
175184
getSettings(client(), getWriteBackingIndex(client(), "logs-apache-production", backingIndex)).get("index.mode"),
176185
indexModeMatcher
177186
);
187+
assertMap(getIndexMappingAsMap(getWriteBackingIndex(client(), "logs-apache-production", backingIndex)), mappingsMatcher);
178188
}
179189

180190
private static Request createDataStream(final String dataStreamName) {

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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;
2021
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2122
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2223
import org.hamcrest.Matcher;
@@ -29,6 +30,9 @@
2930
import java.util.Map;
3031
import java.util.function.Supplier;
3132

33+
import static org.elasticsearch.test.MapMatcher.assertMap;
34+
import static org.elasticsearch.test.MapMatcher.matchesMap;
35+
3236
public class LogsIndexModeRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
3337

3438
@ClassRule()
@@ -156,10 +160,14 @@ public void testLogsIndexing() throws IOException {
156160
assertOK(bulkIndexResponse);
157161
assertThat(entityAsMap(bulkIndexResponse).get("errors"), Matchers.is(false));
158162

159-
assertIndexSettings(0, Matchers.nullValue());
160-
assertIndexSettings(1, Matchers.nullValue());
161-
assertIndexSettings(2, Matchers.nullValue());
162-
assertIndexSettings(3, Matchers.equalTo("logsdb"));
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+
);
163171
}
164172
}
165173

@@ -175,11 +183,13 @@ static void enableLogsdbByDefault() throws IOException {
175183
assertOK(client().performRequest(request));
176184
}
177185

178-
private void assertIndexSettings(int backingIndex, final Matcher<Object> indexModeMatcher) throws IOException {
186+
private void assertIndexMappingsAndSettings(int backingIndex, final Matcher<Object> indexModeMatcher, final MapMatcher mappingsMatcher)
187+
throws IOException {
179188
assertThat(
180189
getSettings(client(), getWriteBackingIndex(client(), "logs-apache-production", backingIndex)).get("index.mode"),
181190
indexModeMatcher
182191
);
192+
assertMap(getIndexMappingAsMap(getWriteBackingIndex(client(), "logs-apache-production", backingIndex)), mappingsMatcher);
183193
}
184194

185195
private static Request createDataStream(final String dataStreamName) {

rest-api-spec/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,4 @@ 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")
6963
})

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ 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+
7984
---
8085
using default timestamp field mapping:
8186
- requires:

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

Lines changed: 8 additions & 7 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_settings:
16+
indices.get:
1717
index: test-default-source
18-
- match: { test-default-source.settings.index.mode: logsdb }
19-
- match: { test-default-source.settings.index.mapping.source.mode: null }
18+
19+
- match: { test-default-source.mappings._source.mode: "synthetic" }
2020

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

3837
---
3938
disabled _source is not supported:
@@ -111,6 +110,7 @@ include/exclude is supported with stored _source:
111110
indices.get:
112111
index: test-includes
113112

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

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

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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ 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+
453458
---
454459
stored source is supported:
455460
- requires:
@@ -481,6 +486,12 @@ stored source is supported:
481486
type: keyword
482487
time_series_dimension: true
483488

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

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

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

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

6059
}
6160

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ 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);
138137
/*
139138
* STOP! READ THIS FIRST! No, really,
140139
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

0 commit comments

Comments
 (0)