Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/138308.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 138308
summary: Reject mappings that (eventually) set dimension and metric in the same field
area: Mapping
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,17 @@ public void doValidate(MappingLookup lookup) {
TimeSeriesParams.TIME_SERIES_DIMENSION_PARAM + " can't be configured in nested field [" + fullPath() + "]"
);
}
if (dimension && metricType != null) {
throw new IllegalArgumentException(
"["
+ TimeSeriesParams.TIME_SERIES_DIMENSION_PARAM
+ "] and ["
+ TimeSeriesParams.TIME_SERIES_METRIC_PARAM
+ "] cannot be set in conjunction with each other ["
+ fullPath()
+ "]"
);
}
}

private SourceLoader.SyntheticFieldLoader docValuesSyntheticFieldLoader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,20 @@ public void testCheckForDuplicatePrioritiesManyElementsDuplicatePriority() throw
);
assertThat(e.getMessage(), containsString("Pass-through object [bar] has a conflicting param [priority=1] with object [foo]"));
}

public void testTimeSeriesDimensionAndMetricConflict() throws IOException {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> createMapperService(mapping(b -> {
b.startObject("labels").field("type", "passthrough").field("priority", "0").field("time_series_dimension", "true");
{
b.startObject("properties");
b.startObject("dim").field("type", "long").field("time_series_metric", "counter").endObject();
b.endObject();
}
b.endObject();
})));
assertThat(
e.getMessage(),
containsString("[time_series_dimension] and [time_series_metric] cannot be set in conjunction with each other [labels.dim]")
);
}
}