Skip to content

Commit de2824b

Browse files
authored
Fix bug introduced when we fixed multi-fields in #138869 (#139104) (#139111)
In #138869 we fixed the handling of the multi-fields; however, we introduced a bug when a mapping contains a alias type. For example, the following mapping: ``` "@timestamp": { "type": "date" }, "timestamp": { "type": "alias", "path": "@timestamp" } ``` The cause of the bug was that in the `FieldValueFetcher` we switch the check wether a field is indexed from the name we retrieved in the label to the name of the field type. In this case, the label is `timestamp` which does not in the indexed but the name of the field type is "@timestamp". (cherry picked from commit 47698be) # Conflicts: # x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleIT.java
1 parent 21a3442 commit de2824b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleIT.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public void testDownsamplingPassthroughDimensions() throws Exception {
4949
{
5050
%s
5151
"properties": {
52+
"@timestamp": {
53+
"type": "date"
54+
},
55+
"timestamp": {
56+
"path": "@timestamp",
57+
"type": "alias"
58+
},
5259
"attributes": {
5360
"type": "passthrough",
5461
"priority": 10,
@@ -92,6 +99,13 @@ public void testDownsamplingPassthroughMetrics() throws Exception {
9299
String mapping = """
93100
{
94101
"properties": {
102+
"@timestamp": {
103+
"type": "date"
104+
},
105+
"timestamp": {
106+
"path": "@timestamp",
107+
"type": "alias"
108+
},
95109
"attributes.os.name": {
96110
"type": "keyword",
97111
"time_series_dimension": true

x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static List<FieldValueFetcher> create(SearchExecutionContext context, String[] f
101101
}
102102
}
103103
} else {
104-
if (context.fieldExistsInIndex(fieldType.name())) {
104+
if (context.fieldExistsInIndex(field)) {
105105
final IndexFieldData<?> fieldData;
106106
if (fieldType instanceof FlattenedFieldMapper.RootFlattenedFieldType flattenedFieldType) {
107107
var keyedFieldType = flattenedFieldType.getKeyedFieldType();

0 commit comments

Comments
 (0)