diff --git a/output/schema/schema.json b/output/schema/schema.json index 29dea3003e..d1d9e8b128 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -8252,16 +8252,26 @@ { "availability": { "stack": { + "featureFlag": "random_sampling", + "since": "9.3.0", "stability": "experimental", - "visibility": "public" + "visibility": "feature_flag" } }, - "description": "Get random sample of ingested data", - "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-sample", + "description": "Request for a random sample of raw documents ingested into the given index or data stream.", + "docId": "random_sample", + "docTag": "random_sample", + "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/group/ingest-random-sampling", "name": "indices.get_sample", - "request": null, + "request": { + "name": "Request", + "namespace": "indices.get_sample" + }, "requestBodyRequired": false, - "response": null, + "response": { + "name": "Response", + "namespace": "indices.get_sample" + }, "responseMediaType": [ "application/json" ], @@ -8277,16 +8287,26 @@ { "availability": { "stack": { + "featureFlag": "random_sampling", + "since": "9.3.0", "stability": "experimental", - "visibility": "public" + "visibility": "feature_flag" } }, - "description": "Get stats about a random sample of ingested data", - "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-sample", + "description": "Request stats for a random sample of raw documents ingested into the given index or data stream.", + "docId": "random_sample", + "docTag": "random_sample", + "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/group/ingest-random-sampling", "name": "indices.get_sample_stats", - "request": null, + "request": { + "name": "Request", + "namespace": "indices.get_sample_stats" + }, "requestBodyRequired": false, - "response": null, + "response": { + "name": "Response", + "namespace": "indices.get_sample_stats" + }, "responseMediaType": [ "application/json" ], @@ -160104,6 +160124,366 @@ ], "specLocation": "indices/get_migrate_reindex_status/MigrateGetReindexStatusResponse.ts#L38-L42" }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "no_body" + }, + "description": "Request for a random sample of raw documents ingested into the given index or data stream.", + "examples": { + "GetRandomSampleRequest1": { + "method_request": "GET /my-index-000001/_sample" + } + }, + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "indices.get_sample" + }, + "path": [ + { + "description": "Single index or data stream name. Wildcards are not supported.", + "name": "index", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "IndexName", + "namespace": "_types" + } + } + } + ], + "query": [], + "specLocation": "indices/get_sample/GetRandomSampleRequest.ts#L23-L44" + }, + { + "kind": "response", + "body": { + "kind": "properties", + "properties": [ + { + "name": "sample", + "required": true, + "type": { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "RawDocument", + "namespace": "indices.get_sample._types" + } + } + } + } + ] + }, + "examples": { + "GetRandomSampleResponse1": { + "description": "A successful response for retrieving the random sample for an index or data stream.", + "value": "{\n \"sample\": [\n {\n \"index\": \"logs\",\n \"source\": {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"Node 0 message\",\n \"user\": {\n \"id\": \"kimchy\"\n },\n \"network\": {\n \"name\": \"Guest\"\n }\n }\n },\n {\n \"index\": \"logs\",\n \"source\": {\n \"@timestamp\": \"2079-11-15T13:12:00\",\n \"message\": \"Node 1 message\",\n \"user\": {\n \"id\": \"kimchy\"\n },\n \"network\": {\n \"name\": \"Guest\"\n }\n }\n }\n ]\n}" + } + }, + "name": { + "name": "Response", + "namespace": "indices.get_sample" + }, + "specLocation": "indices/get_sample/GetRandomSampleResponse.ts#L22-L28" + }, + { + "kind": "interface", + "name": { + "name": "RawDocument", + "namespace": "indices.get_sample._types" + }, + "properties": [ + { + "description": "Name of the index for this raw document.", + "name": "index", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "description": "The original raw source.", + "name": "source", + "required": true, + "type": { + "kind": "dictionary_of", + "key": { + "kind": "instance_of", + "type": { + "name": "PropertyName", + "namespace": "_types" + } + }, + "singleKey": false, + "value": { + "kind": "instance_of", + "type": { + "name": "Property", + "namespace": "_types.mapping" + } + } + } + } + ], + "specLocation": "indices/get_sample/_types/RawDocument.ts#L24-L33" + }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "no_body" + }, + "description": "Request stats for a random sample of raw documents ingested into the given index or data stream.", + "examples": { + "GetRandomSampleStatsRequest1": { + "method_request": "GET /my-index-000001/_sample/stats" + } + }, + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "indices.get_sample_stats" + }, + "path": [ + { + "description": "Single index or data stream name. Wildcards are not supported.", + "name": "index", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "IndexName", + "namespace": "_types" + } + } + } + ], + "query": [], + "specLocation": "indices/get_sample_stats/GetRandomSampleStatsRequest.ts#L23-L44" + }, + { + "kind": "response", + "body": { + "kind": "properties", + "properties": [ + { + "name": "potential_samples", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "samples_rejected_for_max_samples_exceeded", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "samples_rejected_for_condition", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "samples_rejected_for_rate", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "samples_rejected_for_exception", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "samples_rejected_for_size", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "samples_accepted", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "name": "time_sampling", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Duration", + "namespace": "_types" + } + } + }, + { + "name": "time_sampling_millis", + "required": true, + "type": { + "kind": "instance_of", + "generics": [ + { + "kind": "instance_of", + "type": { + "name": "UnitMillis", + "namespace": "_types" + } + } + ], + "type": { + "name": "DurationValue", + "namespace": "_types" + } + } + }, + { + "name": "time_evaluating_condition", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Duration", + "namespace": "_types" + } + } + }, + { + "name": "time_evaluating_condition_millis", + "required": true, + "type": { + "kind": "instance_of", + "generics": [ + { + "kind": "instance_of", + "type": { + "name": "UnitMillis", + "namespace": "_types" + } + } + ], + "type": { + "name": "DurationValue", + "namespace": "_types" + } + } + }, + { + "name": "time_compiling_condition", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Duration", + "namespace": "_types" + } + } + }, + { + "name": "time_compiling_condition_millis", + "required": true, + "type": { + "kind": "instance_of", + "generics": [ + { + "kind": "instance_of", + "type": { + "name": "UnitMillis", + "namespace": "_types" + } + } + ], + "type": { + "name": "DurationValue", + "namespace": "_types" + } + } + }, + { + "name": "last_exception", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + } + ] + }, + "examples": { + "GetRandomSampleStatsResponse1": { + "description": "A successful response for retrieving the random sample stats for an index or data stream.", + "value": "{\n \"potential_samples\": 2,\n \"samples_rejected_for_max_samples_exceeded\": 0,\n \"samples_rejected_for_condition\": 0,\n \"samples_rejected_for_rate\": 0,\n \"samples_rejected_for_exception\": 0,\n \"samples_rejected_for_size\": 0,\n \"samples_accepted\": 2,\n \"time_sampling\": \"415.7micros\",\n \"time_sampling_millis\": 0,\n \"time_evaluating_condition\": \"185.9micros\",\n \"time_evaluating_condition_millis\": 0,\n \"time_compiling_condition\": \"98.4micros\",\n \"time_compiling_condition_millis\": 0\n}" + } + }, + "name": { + "name": "Response", + "namespace": "indices.get_sample_stats" + }, + "specLocation": "indices/get_sample_stats/GetRandomSampleStatsResponse.ts#L23-L44" + }, { "kind": "request", "attachedBehaviors": [ diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 51b9a6eece..2ce5631967 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -12994,6 +12994,40 @@ export interface IndicesGetMigrateReindexStatusStatusInProgress { reindexed_doc_count: long } +export interface IndicesGetSampleRequest extends RequestBase { + index: IndexName +} + +export interface IndicesGetSampleResponse { + sample: IndicesGetSampleRawDocument[] +} + +export interface IndicesGetSampleRawDocument { + index: string + source: Record +} + +export interface IndicesGetSampleStatsRequest extends RequestBase { + index: IndexName +} + +export interface IndicesGetSampleStatsResponse { + potential_samples: long + samples_rejected_for_max_samples_exceeded: long + samples_rejected_for_condition: long + samples_rejected_for_rate: long + samples_rejected_for_exception: long + samples_rejected_for_size: long + samples_accepted: long + time_sampling?: Duration + time_sampling_millis: DurationValue + time_evaluating_condition?: Duration + time_evaluating_condition_millis: DurationValue + time_compiling_condition?: Duration + time_compiling_condition_millis: DurationValue + last_exception?: string +} + export interface IndicesGetSettingsRequest extends RequestBase { index?: Indices name?: Names diff --git a/package.json b/package.json index 13c88d76b8..e121555352 100644 --- a/package.json +++ b/package.json @@ -7,4 +7,4 @@ "@stoplight/spectral-cli": "^6.14.2" }, "version": "overlay" -} \ No newline at end of file +} diff --git a/specification/_doc_ids/table.csv b/specification/_doc_ids/table.csv index 80bdd64d08..c8eaad7102 100644 --- a/specification/_doc_ids/table.csv +++ b/specification/_doc_ids/table.csv @@ -613,6 +613,7 @@ edit-query-rule-from-ui,https://www.elastic.co/docs/solutions/search/query-rules delete-query-rule-from-ui,https://www.elastic.co/docs/solutions/search/query-rules-ui#delete-a-rule,,Delete a rule from the Query Rules UI list-query-rules-in-ui,https://www.elastic.co/docs/solutions/search/query-rules-ui#accessing-the-query-rules-ui,,See rules and rulesets in Query Rules UI delete-query-ruleset-from-ui,https://www.elastic.co/docs/solutions/search/query-rules-ui#delete-a-ruleset,,Delete a ruleset from the Query Rules UI +random_sample,https://www.elastic.co/docs/api/doc/elasticsearch/group/ingest-random-sampling,, realtime,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/docs-get.html, redact-processor,https://www.elastic.co/docs/reference/enrich-processor/redact-processor,, regexp-syntax,https://www.elastic.co/docs/reference/query-languages/query-dsl/regexp-syntax,, diff --git a/specification/_json_spec/indices.get_sample.json b/specification/_json_spec/indices.get_sample.json index 51e783e1ea..90965aa2ae 100644 --- a/specification/_json_spec/indices.get_sample.json +++ b/specification/_json_spec/indices.get_sample.json @@ -5,7 +5,8 @@ "description": "Get random sample of ingested data" }, "stability": "experimental", - "visibility": "public", + "visibility": "feature_flag", + "feature_flag": "random_sampling", "headers": { "accept": ["application/json"] }, diff --git a/specification/indices/get_sample/GetRandomSampleRequest.ts b/specification/indices/get_sample/GetRandomSampleRequest.ts new file mode 100644 index 0000000000..b410a2b01a --- /dev/null +++ b/specification/indices/get_sample/GetRandomSampleRequest.ts @@ -0,0 +1,44 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { RequestBase } from '@_types/Base' +import { IndexName } from '@_types/common' + +/** + * Request for a random sample of raw documents ingested into the given index or data stream. + * + * @rest_spec_name indices.get_sample + * @availability stack visibility=feature_flag feature_flag=random_sampling since=9.3.0 stability=experimental + * @doc_id random_sample + * @doc_tag random_sample + */ +export interface Request extends RequestBase { + urls: [ + { + path: '/{index}/_sample' + methods: ['GET'] + } + ] + path_parts: { + /** + * Single index or data stream name. Wildcards are not supported. + */ + index: IndexName + } +} diff --git a/specification/indices/get_sample/GetRandomSampleResponse.ts b/specification/indices/get_sample/GetRandomSampleResponse.ts new file mode 100644 index 0000000000..86f3927d8c --- /dev/null +++ b/specification/indices/get_sample/GetRandomSampleResponse.ts @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { RawDocument } from './_types/RawDocument' + +/** + * Response type for the get_random_samples API. + * It reuses the standard SearchResponse structure. + */ +export class Response { + body: { sample: RawDocument[] } +} diff --git a/specification/indices/get_sample/_types/RawDocument.ts b/specification/indices/get_sample/_types/RawDocument.ts new file mode 100644 index 0000000000..e3887e9952 --- /dev/null +++ b/specification/indices/get_sample/_types/RawDocument.ts @@ -0,0 +1,33 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PropertyName } from '@_types/common' +import { Property } from '@_types/mapping/Property' +import { Dictionary } from '@spec_utils/Dictionary' + +export class RawDocument { + /** + * Name of the index for this raw document. + */ + index: string + /** + * The original raw source. + */ + source: Dictionary +} diff --git a/specification/indices/get_sample/examples/200_response/GetRandomSampleResponse1.yaml b/specification/indices/get_sample/examples/200_response/GetRandomSampleResponse1.yaml new file mode 100644 index 0000000000..090637a81b --- /dev/null +++ b/specification/indices/get_sample/examples/200_response/GetRandomSampleResponse1.yaml @@ -0,0 +1,35 @@ +# summary: '' +description: A successful response for retrieving the random sample for an index or data stream. +# type: response +# response_code: 200 +value: |- + { + "sample": [ + { + "index": "logs", + "source": { + "@timestamp": "2099-11-15T13:12:00", + "message": "Node 0 message", + "user": { + "id": "kimchy" + }, + "network": { + "name": "Guest" + } + } + }, + { + "index": "logs", + "source": { + "@timestamp": "2079-11-15T13:12:00", + "message": "Node 1 message", + "user": { + "id": "kimchy" + }, + "network": { + "name": "Guest" + } + } + } + ] + } diff --git a/specification/indices/get_sample/examples/request/GetRandomSampleRequest1.yaml b/specification/indices/get_sample/examples/request/GetRandomSampleRequest1.yaml new file mode 100644 index 0000000000..d1451ec58c --- /dev/null +++ b/specification/indices/get_sample/examples/request/GetRandomSampleRequest1.yaml @@ -0,0 +1 @@ +method_request: GET /my-index-000001/_sample diff --git a/specification/indices/get_sample_stats/GetRandomSampleStatsRequest.ts b/specification/indices/get_sample_stats/GetRandomSampleStatsRequest.ts new file mode 100644 index 0000000000..2ff9ef7ba6 --- /dev/null +++ b/specification/indices/get_sample_stats/GetRandomSampleStatsRequest.ts @@ -0,0 +1,44 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { RequestBase } from '@_types/Base' +import { IndexName } from '@_types/common' + +/** + * Request stats for a random sample of raw documents ingested into the given index or data stream. + * + * @rest_spec_name indices.get_sample_stats + * @availability stack visibility=feature_flag feature_flag=random_sampling since=9.3.0 stability=experimental + * @doc_id random_sample + * @doc_tag random_sample + */ +export interface Request extends RequestBase { + urls: [ + { + path: '/{index}/_sample/stats' + methods: ['GET'] + } + ] + path_parts: { + /** + * Single index or data stream name. Wildcards are not supported. + */ + index: IndexName + } +} diff --git a/specification/indices/get_sample_stats/GetRandomSampleStatsResponse.ts b/specification/indices/get_sample_stats/GetRandomSampleStatsResponse.ts new file mode 100644 index 0000000000..16680db9ca --- /dev/null +++ b/specification/indices/get_sample_stats/GetRandomSampleStatsResponse.ts @@ -0,0 +1,44 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { long } from '@_types/Numeric' +import { Duration, DurationValue, UnitMillis } from '@_types/Time' + +/** + * Response type for the get_random_samples API. + * It reuses the standard SearchResponse structure. + */ +export class Response { + body: { + potential_samples: long + samples_rejected_for_max_samples_exceeded: long + samples_rejected_for_condition: long + samples_rejected_for_rate: long + samples_rejected_for_exception: long + samples_rejected_for_size: long + samples_accepted: long + time_sampling?: Duration + time_sampling_millis: DurationValue + time_evaluating_condition?: Duration + time_evaluating_condition_millis: DurationValue + time_compiling_condition?: Duration + time_compiling_condition_millis: DurationValue + last_exception?: string + } +} diff --git a/specification/indices/get_sample_stats/examples/200_response/GetRandomSampleStatsResponse1.yaml b/specification/indices/get_sample_stats/examples/200_response/GetRandomSampleStatsResponse1.yaml new file mode 100644 index 0000000000..18efa69b85 --- /dev/null +++ b/specification/indices/get_sample_stats/examples/200_response/GetRandomSampleStatsResponse1.yaml @@ -0,0 +1,20 @@ +# summary: '' +description: A successful response for retrieving the random sample stats for an index or data stream. +# type: response +# response_code: 200 +value: |- + { + "potential_samples": 2, + "samples_rejected_for_max_samples_exceeded": 0, + "samples_rejected_for_condition": 0, + "samples_rejected_for_rate": 0, + "samples_rejected_for_exception": 0, + "samples_rejected_for_size": 0, + "samples_accepted": 2, + "time_sampling": "415.7micros", + "time_sampling_millis": 0, + "time_evaluating_condition": "185.9micros", + "time_evaluating_condition_millis": 0, + "time_compiling_condition": "98.4micros", + "time_compiling_condition_millis": 0 + } diff --git a/specification/indices/get_sample_stats/examples/request/GetRandomSampleStatsRequest1.yaml b/specification/indices/get_sample_stats/examples/request/GetRandomSampleStatsRequest1.yaml new file mode 100644 index 0000000000..a8589a40ce --- /dev/null +++ b/specification/indices/get_sample_stats/examples/request/GetRandomSampleStatsRequest1.yaml @@ -0,0 +1 @@ +method_request: GET /my-index-000001/_sample/stats