From 346085d5804cbf1d1a8b7037a31a15b82ac2481f Mon Sep 17 00:00:00 2001 From: gmarouli Date: Wed, 15 Oct 2025 18:36:20 +0300 Subject: [PATCH 1/5] Add new sampling method to the downsample API --- specification/indices/_types/Downsample.ts | 9 +++++++++ specification/indices/downsample/Request.ts | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/specification/indices/_types/Downsample.ts b/specification/indices/_types/Downsample.ts index f34526fc48..f2f2aeda35 100644 --- a/specification/indices/_types/Downsample.ts +++ b/specification/indices/_types/Downsample.ts @@ -24,4 +24,13 @@ export class DownsampleConfig { * The interval at which to aggregate the original time series index. */ fixed_interval: DurationLarge + /** + * The sampling method used to reduce the documents; it can be either `aggregate` or `last_value`. Defaults to `aggregate`. + */ + sampling_method?: SamplingMethod } + +enum SamplingMethod { + aggregate, + last_value +} \ No newline at end of file diff --git a/specification/indices/downsample/Request.ts b/specification/indices/downsample/Request.ts index 64e32d4d41..1e583a4261 100644 --- a/specification/indices/downsample/Request.ts +++ b/specification/indices/downsample/Request.ts @@ -23,7 +23,11 @@ import { DownsampleConfig } from '@indices/_types/Downsample' /** * Downsample an index. - * Aggregate a time series (TSDS) index and store pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval. + * Downsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics: + * + * - When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) + * for each metric field grouped by a configured time interval and their dimensions. + * - When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions. * For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. * All documents within an hour interval are summarized and stored as a single document in the downsample index. * From 021b0a9165091b0d739528e6292ca1732e9a7daa Mon Sep 17 00:00:00 2001 From: gmarouli Date: Wed, 15 Oct 2025 18:46:28 +0300 Subject: [PATCH 2/5] Commit generated files --- output/schema/schema.json | 36 ++++++++++++++++++++++++++++++++---- output/typescript/types.ts | 3 +++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index dbffa0b55a..417279fd62 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -7348,7 +7348,7 @@ "stability": "experimental" } }, - "description": "Downsample an index.\nAggregate a time series (TSDS) index and store pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", + "description": "Downsample an index.\nDownsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", "docId": "indices-downsample-data-stream", "docTag": "data stream", "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-downsample", @@ -148414,9 +148414,21 @@ "namespace": "_types" } } + }, + { + "description": "The sampling method used to reduce the documents; it can be either `aggregate` or `last_value`. Defaults to `aggregate`.", + "name": "sampling_method", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "SamplingMethod", + "namespace": "indices._types" + } + } } ], - "specLocation": "indices/_types/Downsample.ts#L22-L27" + "specLocation": "indices/_types/Downsample.ts#L22-L31" }, { "kind": "interface", @@ -151378,6 +151390,22 @@ ], "specLocation": "indices/_types/IndexSettings.ts#L66-L68" }, + { + "kind": "enum", + "members": [ + { + "name": "aggregate" + }, + { + "name": "last_value" + } + ], + "name": { + "name": "SamplingMethod", + "namespace": "indices._types" + }, + "specLocation": "indices/_types/Downsample.ts#L33-L36" + }, { "kind": "interface", "name": { @@ -156063,7 +156091,7 @@ } } }, - "description": "Downsample an index.\nAggregate a time series (TSDS) index and store pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", + "description": "Downsample an index.\nDownsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", "examples": { "DownsampleRequestExample1": { "alternatives": [ @@ -156129,7 +156157,7 @@ } ], "query": [], - "specLocation": "indices/downsample/Request.ts#L24-L58" + "specLocation": "indices/downsample/Request.ts#L24-L62" }, { "kind": "response", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index a90a0dd993..5eb1fad5ed 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -11911,6 +11911,7 @@ export interface IndicesDataStreamVisibility { export interface IndicesDownsampleConfig { fixed_interval: DurationLarge + sampling_method?: IndicesSamplingMethod } export interface IndicesDownsamplingRound { @@ -12211,6 +12212,8 @@ export interface IndicesRetentionLease { period: Duration } +export type IndicesSamplingMethod = 'aggregate' | 'last_value' + export interface IndicesSearchIdle { after?: Duration } From 89956d4babe4c0cf8d51de11219e71e5798d115c Mon Sep 17 00:00:00 2001 From: gmarouli Date: Wed, 15 Oct 2025 18:50:01 +0300 Subject: [PATCH 3/5] add new line --- specification/indices/_types/Downsample.ts | 2 +- specification/indices/downsample/Request.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/specification/indices/_types/Downsample.ts b/specification/indices/_types/Downsample.ts index f2f2aeda35..46fa228a0c 100644 --- a/specification/indices/_types/Downsample.ts +++ b/specification/indices/_types/Downsample.ts @@ -33,4 +33,4 @@ export class DownsampleConfig { enum SamplingMethod { aggregate, last_value -} \ No newline at end of file +} diff --git a/specification/indices/downsample/Request.ts b/specification/indices/downsample/Request.ts index 1e583a4261..aad79a81b6 100644 --- a/specification/indices/downsample/Request.ts +++ b/specification/indices/downsample/Request.ts @@ -28,6 +28,7 @@ import { DownsampleConfig } from '@indices/_types/Downsample' * - When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) * for each metric field grouped by a configured time interval and their dimensions. * - When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions. + * * For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. * All documents within an hour interval are summarized and stored as a single document in the downsample index. * From 18117114e2dbb76e5033eff017106a25028eee65 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Wed, 15 Oct 2025 19:04:21 +0300 Subject: [PATCH 4/5] Fix formatting --- specification/indices/downsample/Request.ts | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/specification/indices/downsample/Request.ts b/specification/indices/downsample/Request.ts index aad79a81b6..2b7d595656 100644 --- a/specification/indices/downsample/Request.ts +++ b/specification/indices/downsample/Request.ts @@ -17,9 +17,9 @@ * under the License. */ -import { RequestBase } from '@_types/Base' -import { IndexName } from '@_types/common' -import { DownsampleConfig } from '@indices/_types/Downsample' +import { RequestBase } from "@_types/Base"; +import { IndexName } from "@_types/common"; +import { DownsampleConfig } from "@indices/_types/Downsample"; /** * Downsample an index. @@ -28,7 +28,7 @@ import { DownsampleConfig } from '@indices/_types/Downsample' * - When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) * for each metric field grouped by a configured time interval and their dimensions. * - When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions. - * + * * For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. * All documents within an hour interval are summarized and stored as a single document in the downsample index. * @@ -44,20 +44,20 @@ import { DownsampleConfig } from '@indices/_types/Downsample' export interface Request extends RequestBase { urls: [ { - path: '/{index}/_downsample/{target_index}' - methods: ['POST'] - } - ] + path: "/{index}/_downsample/{target_index}"; + methods: ["POST"]; + }, + ]; path_parts: { /** * Name of the time series index to downsample. */ - index: IndexName + index: IndexName; /** * Name of the index to create. */ - target_index: IndexName - } + target_index: IndexName; + }; /** @codegen_name config */ - body: DownsampleConfig + body: DownsampleConfig; } From ec925827105972af080d775d30d8dbfdf27262bd Mon Sep 17 00:00:00 2001 From: gmarouli Date: Wed, 15 Oct 2025 19:12:52 +0300 Subject: [PATCH 5/5] Run `make contrib` --- output/openapi/elasticsearch-openapi.json | 17 +++++++++++++- .../elasticsearch-serverless-openapi.json | 15 +++++++++++++ output/schema/schema.json | 6 ++--- specification/indices/downsample/Request.ts | 22 +++++++++---------- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 1129e9883f..5163b7c429 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -16589,7 +16589,7 @@ "data stream" ], "summary": "Downsample an index", - "description": "Aggregate a time series (TSDS) index and store pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", + "description": "Downsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\n\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", "operationId": "indices-downsample", "parameters": [ { @@ -88361,12 +88361,27 @@ "$ref": "#/components/schemas/_types.DurationLarge" } ] + }, + "sampling_method": { + "description": "The sampling method used to reduce the documents; it can be either `aggregate` or `last_value`. Defaults to `aggregate`.", + "allOf": [ + { + "$ref": "#/components/schemas/indices._types.SamplingMethod" + } + ] } }, "required": [ "fixed_interval" ] }, + "indices._types.SamplingMethod": { + "type": "string", + "enum": [ + "aggregate", + "last_value" + ] + }, "indices._types.DataStreamOptionsTemplate": { "description": "Data stream options template contains the same information as DataStreamOptions but allows them to be set explicitly to null.", "type": "object", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index b46ac50cfe..38cbc1c468 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -60600,12 +60600,27 @@ "$ref": "#/components/schemas/_types.DurationLarge" } ] + }, + "sampling_method": { + "description": "The sampling method used to reduce the documents; it can be either `aggregate` or `last_value`. Defaults to `aggregate`.", + "allOf": [ + { + "$ref": "#/components/schemas/indices._types.SamplingMethod" + } + ] } }, "required": [ "fixed_interval" ] }, + "indices._types.SamplingMethod": { + "type": "string", + "enum": [ + "aggregate", + "last_value" + ] + }, "indices._types.DataStreamOptionsTemplate": { "description": "Data stream options template contains the same information as DataStreamOptions but allows them to be set explicitly to null.", "type": "object", diff --git a/output/schema/schema.json b/output/schema/schema.json index 417279fd62..53e76f2117 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -7348,7 +7348,7 @@ "stability": "experimental" } }, - "description": "Downsample an index.\nDownsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", + "description": "Downsample an index.\nDownsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\n\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", "docId": "indices-downsample-data-stream", "docTag": "data stream", "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-downsample", @@ -156091,7 +156091,7 @@ } } }, - "description": "Downsample an index.\nDownsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", + "description": "Downsample an index.\nDownsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:\n\n- When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)\nfor each metric field grouped by a configured time interval and their dimensions.\n- When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.\n\nFor example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.\nAll documents within an hour interval are summarized and stored as a single document in the downsample index.\n\nNOTE: Only indices in a time series data stream are supported.\nNeither field nor document level security can be defined on the source index.\nThe source index must be read only (`index.blocks.write: true`).", "examples": { "DownsampleRequestExample1": { "alternatives": [ @@ -156157,7 +156157,7 @@ } ], "query": [], - "specLocation": "indices/downsample/Request.ts#L24-L62" + "specLocation": "indices/downsample/Request.ts#L24-L63" }, { "kind": "response", diff --git a/specification/indices/downsample/Request.ts b/specification/indices/downsample/Request.ts index 2b7d595656..3725feb7c4 100644 --- a/specification/indices/downsample/Request.ts +++ b/specification/indices/downsample/Request.ts @@ -17,9 +17,9 @@ * under the License. */ -import { RequestBase } from "@_types/Base"; -import { IndexName } from "@_types/common"; -import { DownsampleConfig } from "@indices/_types/Downsample"; +import { RequestBase } from '@_types/Base' +import { IndexName } from '@_types/common' +import { DownsampleConfig } from '@indices/_types/Downsample' /** * Downsample an index. @@ -44,20 +44,20 @@ import { DownsampleConfig } from "@indices/_types/Downsample"; export interface Request extends RequestBase { urls: [ { - path: "/{index}/_downsample/{target_index}"; - methods: ["POST"]; - }, - ]; + path: '/{index}/_downsample/{target_index}' + methods: ['POST'] + } + ] path_parts: { /** * Name of the time series index to downsample. */ - index: IndexName; + index: IndexName /** * Name of the index to create. */ - target_index: IndexName; - }; + target_index: IndexName + } /** @codegen_name config */ - body: DownsampleConfig; + body: DownsampleConfig }