From 8a1ac79c89d97327ddb27413529967ec6ffdf217 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 22 Nov 2024 11:56:18 +0400 Subject: [PATCH] Fix async_search query parameter validation --- output/openapi/elasticsearch-openapi.json | 26 +++++++-------- .../elasticsearch-serverless-openapi.json | 26 +++++++-------- output/schema/schema-serverless.json | 32 +++++++++++-------- output/schema/schema.json | 32 +++++++++++-------- output/schema/validation-errors.json | 10 ------ output/typescript/types.ts | 2 +- .../_json_spec/async_search.submit.json | 15 +++++++++ .../status/AsyncSearchStatusRequest.ts | 9 ++++++ .../submit/AsyncSearchSubmitRequest.ts | 5 +-- 9 files changed, 86 insertions(+), 71 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 3a9dec8c5f..53989f253b 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" }, @@ -92820,15 +92824,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", @@ -92955,6 +92950,7 @@ "async_search.submit#rest_total_hits_as_int": { "in": "query", "name": "rest_total_hits_as_int", + "description": "Indicates whether hits.total should be rendered as an integer or an object in the rest search response", "deprecated": false, "schema": { "type": "boolean" diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index a00e2e5e50..f6ca944eaf 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" }, @@ -56929,15 +56933,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", @@ -57064,6 +57059,7 @@ "async_search.submit#rest_total_hits_as_int": { "in": "query", "name": "rest_total_hits_as_int", + "description": "Indicates whether hits.total should be rendered as an integer or an object in the rest search response", "deprecated": false, "schema": { "type": "boolean" diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 7ab7e54163..7daa1f0235 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", @@ -11088,6 +11091,7 @@ } }, { + "description": "Indicates whether hits.total should be rendered as an integer or an object in the rest search response", "name": "rest_total_hits_as_int", "required": false, "type": { @@ -11222,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 8bab6eef67..3aac85f2fb 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -87549,8 +87549,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", @@ -88402,17 +88416,6 @@ } } }, - { - "name": "scroll", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "Duration", - "namespace": "_types" - } - } - }, { "description": "Search operation type", "name": "search_type", @@ -88561,6 +88564,7 @@ } }, { + "description": "Indicates whether hits.total should be rendered as an integer or an object in the rest search response", "name": "rest_total_hits_as_int", "required": false, "type": { @@ -88695,7 +88699,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 b2b561784c..603c3c6af0 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -49,18 +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 'ccs_minimize_roundtrips' does not exist in the json spec", - "Request: query parameter 'pre_filter_shard_size' does not exist in the json spec", - "Request: query parameter 'scroll' does not exist in the json spec", - "Request: query parameter 'rest_total_hits_as_int' 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 6aa988b8c5..6262bd97fa 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -6737,6 +6737,7 @@ export type AsyncSearchGetResponse = AsyncSearchAsyncSearch export interface AsyncSearchStatusRequest extends RequestBase { id: Id + keep_alive?: Duration } export type AsyncSearchStatusResponse = AsyncSearchStatusStatusResponseBase @@ -6771,7 +6772,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/_json_spec/async_search.submit.json b/specification/_json_spec/async_search.submit.json index 05222cd16c..628a79a4e9 100644 --- a/specification/_json_spec/async_search.submit.json +++ b/specification/_json_spec/async_search.submit.json @@ -61,6 +61,11 @@ "type": "boolean", "description": "Specify whether wildcard and prefix queries should be analyzed (default: false)" }, + "ccs_minimize_roundtrips": { + "type": "boolean", + "default": false, + "description": "When doing a cross-cluster search, setting it to true may improve overall search latency, particularly when searching clusters with a large number of shards. However, when set to true, the progress of searches on the remote clusters will not be received until the search finishes on all clusters." + }, "default_operator": { "type": "enum", "options": ["AND", "OR"], @@ -113,6 +118,16 @@ "type": "string", "description": "Specify the node or shard the operation should be performed on (default: random)" }, + "pre_filter_shard_size": { + "type": "number", + "default": 1, + "description": "Cannot be changed: this is to enforce the execution of a pre-filter roundtrip to retrieve statistics from each shard so that the ones that surely don’t hold any document matching the query get skipped." + }, + "rest_total_hits_as_int": { + "type": "boolean", + "description": "Indicates whether hits.total should be rendered as an integer or an object in the rest search response", + "default": false + }, "q": { "type": "string", "description": "Query in the Lucene query string syntax" 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