diff --git a/docs/changelog/87100.yaml b/docs/changelog/87100.yaml new file mode 100644 index 0000000000000..42a3ff29b3438 --- /dev/null +++ b/docs/changelog/87100.yaml @@ -0,0 +1,5 @@ +pr: 87100 +summary: Give doc-value-only mappings to numeric fields on metrics templates +area: Data streams +type: enhancement +issues: [] diff --git a/x-pack/plugin/core/src/main/resources/metrics-mappings.json b/x-pack/plugin/core/src/main/resources/metrics-mappings.json index e41863f282dce..743c98d196a16 100644 --- a/x-pack/plugin/core/src/main/resources/metrics-mappings.json +++ b/x-pack/plugin/core/src/main/resources/metrics-mappings.json @@ -1,6 +1,26 @@ { "template": { "mappings": { + "dynamic_templates": [ + { + "long_metrics": { + "match_mapping_type": "long", + "mapping": { + "type": "long", + "index": false + } + } + }, + { + "double_metrics": { + "match_mapping_type": "double", + "mapping": { + "type": "float", + "index": false + } + } + } + ], "properties": { "data_stream": { "properties": { diff --git a/x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml b/x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml index 4138d1577bcf4..4c2d570b2f70b 100644 --- a/x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml +++ b/x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml @@ -102,6 +102,8 @@ setup: data_stream.type: "metrics" data_stream.dataset: "foo" data_stream.namespace: "bar" + my.counter: 42 + my.gauge: 2.3 - do: indices.get_data_stream: @@ -129,6 +131,10 @@ setup: - match: { .$idx0name.mappings.properties.data_stream.properties.namespace.type: "constant_keyword" } - match: { .$idx0name.mappings.properties.data_stream.properties.namespace.value: "bar" } - match: { .$idx0name.mappings.properties.source.properties.ip.type: "ip" } + - match: { .$idx0name.mappings.properties.my.properties.counter.type: "long" } + - match: { .$idx0name.mappings.properties.my.properties.counter.index: false } + - match: { .$idx0name.mappings.properties.my.properties.gauge.type: "float" } + - match: { .$idx0name.mappings.properties.my.properties.gauge.index: false } - match: { .$idx0name.data_stream: "metrics-foo-bar" } - do: diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java index 5393f95d6c776..c03e213c7fdbd 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java @@ -37,7 +37,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry { // The stack template registry version. This number must be incremented when we make changes // to built-in templates. - public static final int REGISTRY_VERSION = 1; + public static final int REGISTRY_VERSION = 2; public static final String TEMPLATE_VERSION_VARIABLE = "xpack.stack.template.version"; public static final Setting STACK_TEMPLATES_ENABLED = Setting.boolSetting(