From db7943eb40399d122e30242961c335428d81ab20 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 26 Nov 2024 17:55:02 +0400 Subject: [PATCH] Fix async_search query parameter validation (#3167) --- output/openapi/elasticsearch-openapi.json | 25 ++++++--------- .../elasticsearch-serverless-openapi.json | 25 ++++++--------- output/schema/schema-serverless.json | 31 ++++++++++--------- output/schema/schema.json | 31 ++++++++++--------- output/schema/validation-errors.json | 7 ----- output/typescript/types.ts | 2 +- .../status/AsyncSearchStatusRequest.ts | 9 ++++++ .../submit/AsyncSearchSubmitRequest.ts | 5 +-- 8 files changed, 67 insertions(+), 68 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 20d2ad8206..4f7aa86093 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -128,6 +128,16 @@ "$ref": "#/components/schemas/_types:Id" }, "style": "simple" + }, + { + "in": "query", + "name": "keep_alive", + "description": "Specifies how long the async search needs to be available.\nOngoing async searches and any saved search results are deleted after this period.", + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:Duration" + }, + "style": "form" } ], "responses": { @@ -220,9 +230,6 @@ { "$ref": "#/components/parameters/async_search.submit#routing" }, - { - "$ref": "#/components/parameters/async_search.submit#scroll" - }, { "$ref": "#/components/parameters/async_search.submit#search_type" }, @@ -379,9 +386,6 @@ { "$ref": "#/components/parameters/async_search.submit#routing" }, - { - "$ref": "#/components/parameters/async_search.submit#scroll" - }, { "$ref": "#/components/parameters/async_search.submit#search_type" }, @@ -92887,15 +92891,6 @@ }, "style": "form" }, - "async_search.submit#scroll": { - "in": "query", - "name": "scroll", - "deprecated": false, - "schema": { - "$ref": "#/components/schemas/_types:Duration" - }, - "style": "form" - }, "async_search.submit#search_type": { "in": "query", "name": "search_type", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 18577e20da..d907d66327 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -128,6 +128,16 @@ "$ref": "#/components/schemas/_types:Id" }, "style": "simple" + }, + { + "in": "query", + "name": "keep_alive", + "description": "Specifies how long the async search needs to be available.\nOngoing async searches and any saved search results are deleted after this period.", + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:Duration" + }, + "style": "form" } ], "responses": { @@ -220,9 +230,6 @@ { "$ref": "#/components/parameters/async_search.submit#routing" }, - { - "$ref": "#/components/parameters/async_search.submit#scroll" - }, { "$ref": "#/components/parameters/async_search.submit#search_type" }, @@ -379,9 +386,6 @@ { "$ref": "#/components/parameters/async_search.submit#routing" }, - { - "$ref": "#/components/parameters/async_search.submit#scroll" - }, { "$ref": "#/components/parameters/async_search.submit#search_type" }, @@ -57036,15 +57040,6 @@ }, "style": "form" }, - "async_search.submit#scroll": { - "in": "query", - "name": "scroll", - "deprecated": false, - "schema": { - "$ref": "#/components/schemas/_types:Duration" - }, - "style": "form" - }, "async_search.submit#search_type": { "in": "query", "name": "search_type", diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index d59a6830d5..eb557fa737 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -10128,8 +10128,22 @@ } } ], - "query": [], - "specLocation": "async_search/status/AsyncSearchStatusRequest.ts#L23-L39" + "query": [ + { + "description": "Specifies how long the async search needs to be available.\nOngoing async searches and any saved search results are deleted after this period.", + "name": "keep_alive", + "required": false, + "serverDefault": "5d", + "type": { + "kind": "instance_of", + "type": { + "name": "Duration", + "namespace": "_types" + } + } + } + ], + "specLocation": "async_search/status/AsyncSearchStatusRequest.ts#L24-L48" }, { "body": { @@ -10929,17 +10943,6 @@ } } }, - { - "name": "scroll", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "Duration", - "namespace": "_types" - } - } - }, { "description": "Search operation type", "name": "search_type", @@ -11223,7 +11226,7 @@ } } ], - "specLocation": "async_search/submit/AsyncSearchSubmitRequest.ts#L54-L288" + "specLocation": "async_search/submit/AsyncSearchSubmitRequest.ts#L54-L289" }, { "body": { diff --git a/output/schema/schema.json b/output/schema/schema.json index f714f70753..3ff4a3f601 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -87620,8 +87620,22 @@ } } ], - "query": [], - "specLocation": "async_search/status/AsyncSearchStatusRequest.ts#L23-L39" + "query": [ + { + "description": "Specifies how long the async search needs to be available.\nOngoing async searches and any saved search results are deleted after this period.", + "name": "keep_alive", + "required": false, + "serverDefault": "5d", + "type": { + "kind": "instance_of", + "type": { + "name": "Duration", + "namespace": "_types" + } + } + } + ], + "specLocation": "async_search/status/AsyncSearchStatusRequest.ts#L24-L48" }, { "kind": "response", @@ -88473,17 +88487,6 @@ } } }, - { - "name": "scroll", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "Duration", - "namespace": "_types" - } - } - }, { "description": "Search operation type", "name": "search_type", @@ -88767,7 +88770,7 @@ } } ], - "specLocation": "async_search/submit/AsyncSearchSubmitRequest.ts#L54-L288" + "specLocation": "async_search/submit/AsyncSearchSubmitRequest.ts#L54-L289" }, { "kind": "response", diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index 6d1a376baa..041f98de05 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -49,15 +49,8 @@ "type_alias definition _global.search._types:Suggest - Expected 1 generic parameters but got 0" ] }, - "async_search.status": { - "request": [ - "Request: missing json spec query parameter 'keep_alive'" - ], - "response": [] - }, "async_search.submit": { "request": [ - "Request: query parameter 'scroll' does not exist in the json spec", "interface definition _types:QueryVectorBuilder - Property text_embedding is a single-variant and must be required", "type_alias definition _spec_utils:PipeSeparatedFlags / union_of / instance_of - No type definition for '_spec_utils.PipeSeparatedFlags:T'" ], diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 8c4547d376..51b260f56a 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -6747,6 +6747,7 @@ export type AsyncSearchGetResponse = AsyncSearchAsyncSearch export interface AsyncSearchStatusRequest extends RequestBase { id: Id + keep_alive?: Duration } export type AsyncSearchStatusResponse = AsyncSearchStatusStatusResponseBase @@ -6781,7 +6782,6 @@ export interface AsyncSearchSubmitRequest extends RequestBase { pre_filter_shard_size?: long request_cache?: boolean routing?: Routing - scroll?: Duration search_type?: SearchType stats?: string[] stored_fields?: Fields diff --git a/specification/async_search/status/AsyncSearchStatusRequest.ts b/specification/async_search/status/AsyncSearchStatusRequest.ts index 4a8f4f7816..e8b09d88b5 100644 --- a/specification/async_search/status/AsyncSearchStatusRequest.ts +++ b/specification/async_search/status/AsyncSearchStatusRequest.ts @@ -19,6 +19,7 @@ import { RequestBase } from '@_types/Base' import { Id } from '@_types/common' +import { Duration } from '@_types/Time' /** * Get the async search status. @@ -36,4 +37,12 @@ export interface Request extends RequestBase { /** A unique identifier for the async search. */ id: Id } + query_parameters: { + /** + * Specifies how long the async search needs to be available. + * Ongoing async searches and any saved search results are deleted after this period. + * @server_default 5d + */ + keep_alive?: Duration + } } diff --git a/specification/async_search/submit/AsyncSearchSubmitRequest.ts b/specification/async_search/submit/AsyncSearchSubmitRequest.ts index 3702595468..6154bcfbb8 100644 --- a/specification/async_search/submit/AsyncSearchSubmitRequest.ts +++ b/specification/async_search/submit/AsyncSearchSubmitRequest.ts @@ -66,7 +66,9 @@ import { Duration } from '@_types/Time' * @doc_id async-search * @doc_tag search */ -// NOTE: this is a SearchRequest with 3 added parameters: wait_for_completion_timeout, keep_on_completion and keep_alive +// NOTE: this is a SearchRequest with: +// * 3 added parameters: wait_for_completion_timeout, keep_on_completion and keep_alive +// * 1 removed parameters: scroll export interface Request extends RequestBase { path_parts: { index?: Indices @@ -122,7 +124,6 @@ export interface Request extends RequestBase { /** @server_default true */ request_cache?: boolean routing?: Routing - scroll?: Duration search_type?: SearchType stats?: string[] stored_fields?: Fields