Skip to content

Commit 24037d6

Browse files
authored
Exclude synthetic source test for TSDB from mixedClusterTests (elastic#100592)
* Don't print synthetic source in mapping for bwc tests * Move comment. * Don't print synthetic source in mapping for bwc tests #2 * Don't print synthetic source in mapping for bwc tests #2 * Revert "Don't print synthetic source in mapping for bwc tests #2" This reverts commit 034262c. * Revert "Don't print synthetic source in mapping for bwc tests #2" This reverts commit 44e8156. * Revert "Don't print synthetic source in mapping for bwc tests (elastic#100572)" This reverts commit 9322ab9. * Exclude synthetic source test from mixedClusterTests * Update comment.
1 parent 5dc7ccc commit 24037d6

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

qa/mixed-cluster/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ excludeList.add('aggregations/filter/Standard queries get cached')
4141
excludeList.add('aggregations/filter/Terms lookup gets cached')
4242
excludeList.add('aggregations/filters_bucket/cache hits')
4343

44+
// The test checks that tsdb mappings report source as synthetic.
45+
// It is supposed to be skipped (not needed) for versions before
46+
// 8.10 but mixed cluster tests may not respect that - see the
47+
// comment above.
48+
excludeList.add('tsdb/20_mapping/Synthetic source')
49+
4450
BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
4551

4652
if (bwcVersion != VersionProperties.getElasticsearchVersion()) {

server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,20 @@ public static class Builder extends MetadataFieldMapper.Builder {
101101
(previous, current, conflicts) -> (previous.value() == current.value()) || (previous.value() && current.value() == false)
102102
);
103103

104-
private final Parameter<Mode> mode;
104+
/*
105+
* The default mode for TimeSeries is left empty on purpose, so that mapping printings include the synthetic
106+
* source mode.
107+
*/
108+
private final Parameter<Mode> mode = new Parameter<>(
109+
"mode",
110+
true,
111+
() -> null,
112+
(n, c, o) -> Mode.valueOf(o.toString().toUpperCase(Locale.ROOT)),
113+
m -> toType(m).enabled.explicit() ? null : toType(m).mode,
114+
(b, n, v) -> b.field(n, v.toString().toLowerCase(Locale.ROOT)),
115+
v -> v.toString().toLowerCase(Locale.ROOT)
116+
).setMergeValidator((previous, current, conflicts) -> (previous == current) || current != Mode.STORED)
117+
.setSerializerCheck((includeDefaults, isConfigured, value) -> value != null); // don't emit if `enabled` is configured
105118
private final Parameter<List<String>> includes = Parameter.stringArrayParam(
106119
"includes",
107120
false,
@@ -115,22 +128,9 @@ public static class Builder extends MetadataFieldMapper.Builder {
115128

116129
private final IndexMode indexMode;
117130

118-
public Builder(IndexMode indexMode, IndexVersion indexVersion) {
131+
public Builder(IndexMode indexMode) {
119132
super(Defaults.NAME);
120133
this.indexMode = indexMode;
121-
this.mode = new Parameter<>(
122-
"mode",
123-
true,
124-
// The default mode for TimeSeries is left empty on purpose, so that mapping printings include the synthetic source mode.
125-
() -> getIndexMode() == IndexMode.TIME_SERIES && indexVersion.between(IndexVersion.V_8_7_0, IndexVersion.V_8_10_0)
126-
? Mode.SYNTHETIC
127-
: null,
128-
(n, c, o) -> Mode.valueOf(o.toString().toUpperCase(Locale.ROOT)),
129-
m -> toType(m).enabled.explicit() ? null : toType(m).mode,
130-
(b, n, v) -> b.field(n, v.toString().toLowerCase(Locale.ROOT)),
131-
v -> v.toString().toLowerCase(Locale.ROOT)
132-
).setMergeValidator((previous, current, conflicts) -> (previous == current) || current != Mode.STORED)
133-
.setSerializerCheck((includeDefaults, isConfigured, value) -> value != null); // don't emit if `enabled` is configured
134134
}
135135

136136
public Builder setSynthetic() {
@@ -188,7 +188,7 @@ private IndexMode getIndexMode() {
188188
c -> c.getIndexSettings().getMode() == IndexMode.TIME_SERIES
189189
? c.getIndexSettings().getIndexVersionCreated().onOrAfter(IndexVersion.V_8_7_0) ? TSDB_DEFAULT : TSDB_LEGACY_DEFAULT
190190
: DEFAULT,
191-
c -> new Builder(c.getIndexSettings().getMode(), c.getIndexSettings().getIndexVersionCreated())
191+
c -> new Builder(c.getIndexSettings().getMode())
192192
);
193193

194194
static final class SourceFieldType extends MappedFieldType {
@@ -313,7 +313,7 @@ protected String contentType() {
313313

314314
@Override
315315
public FieldMapper.Builder getMergeBuilder() {
316-
return new Builder(indexMode, IndexVersion.current()).init(this);
316+
return new Builder(indexMode).init(this);
317317
}
318318

319319
/**

server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import org.elasticsearch.common.bytes.BytesArray;
1313
import org.elasticsearch.common.bytes.BytesReference;
1414
import org.elasticsearch.common.xcontent.XContentHelper;
15-
import org.elasticsearch.index.IndexMode;
16-
import org.elasticsearch.index.IndexVersion;
1715
import org.elasticsearch.xcontent.XContentBuilder;
1816
import org.elasticsearch.xcontent.XContentFactory;
1917
import org.elasticsearch.xcontent.XContentParser;
@@ -240,10 +238,4 @@ public void testSyntheticSourceInTimeSeries() throws IOException {
240238
assertTrue(mapper.sourceMapper().isSynthetic());
241239
assertEquals("{\"_source\":{\"mode\":\"synthetic\"}}", mapper.sourceMapper().toString());
242240
}
243-
244-
public void testSyntheticSourceInTimeSeriesBwc() throws IOException {
245-
SourceFieldMapper sourceMapper = new SourceFieldMapper.Builder(IndexMode.TIME_SERIES, IndexVersion.V_8_8_0).build();
246-
assertTrue(sourceMapper.isSynthetic());
247-
assertEquals("{\"_source\":{\"mode\":\"synthetic\"}}", sourceMapper.toString());
248-
}
249241
}

server/src/test/java/org/elasticsearch/index/query/SearchExecutionContextTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public void testSearchRequestRuntimeFieldsAndMultifieldDetection() {
381381

382382
public void testSyntheticSourceSearchLookup() throws IOException {
383383
// Build a mapping using synthetic source
384-
SourceFieldMapper sourceMapper = new SourceFieldMapper.Builder(null, IndexVersion.current()).setSynthetic().build();
384+
SourceFieldMapper sourceMapper = new SourceFieldMapper.Builder(null).setSynthetic().build();
385385
RootObjectMapper root = new RootObjectMapper.Builder("_doc", Explicit.IMPLICIT_TRUE).add(
386386
new KeywordFieldMapper.Builder("cat", IndexVersion.current()).ignoreAbove(100)
387387
).build(MapperBuilderContext.root(true, false));

0 commit comments

Comments
 (0)