From c195be838152699687e2ea0e9f064e441a050561 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 30 Oct 2025 16:08:53 +0400 Subject: [PATCH] Allow single function in FunctionScoreQuery.functions --- output/openapi/elasticsearch-openapi.json | 15 ++++++++--- .../elasticsearch-serverless-openapi.json | 15 ++++++++--- output/schema/schema.json | 26 ++++++++++++++----- output/typescript/types.ts | 4 +-- specification/_types/query_dsl/compound.ts | 2 +- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index a2337397e8..1a3055620a 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -61532,10 +61532,17 @@ }, "functions": { "description": "One or more functions that compute a new score for each document returned by the query.", - "type": "array", - "items": { - "$ref": "#/components/schemas/_types.query_dsl.FunctionScoreContainer" - } + "oneOf": [ + { + "$ref": "#/components/schemas/_types.query_dsl.FunctionScoreContainer" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/_types.query_dsl.FunctionScoreContainer" + } + } + ] }, "max_boost": { "description": "Restricts the new score to not exceed the provided limit.", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index fe34c83b3c..47af98d028 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -37764,10 +37764,17 @@ }, "functions": { "description": "One or more functions that compute a new score for each document returned by the query.", - "type": "array", - "items": { - "$ref": "#/components/schemas/_types.query_dsl.FunctionScoreContainer" - } + "oneOf": [ + { + "$ref": "#/components/schemas/_types.query_dsl.FunctionScoreContainer" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/_types.query_dsl.FunctionScoreContainer" + } + } + ] }, "max_boost": { "description": "Restricts the new score to not exceed the provided limit.", diff --git a/output/schema/schema.json b/output/schema/schema.json index 3b4fd524e7..364497a8e1 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -91373,14 +91373,26 @@ "name": "functions", "required": false, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "FunctionScoreContainer", - "namespace": "_types.query_dsl" + "kind": "union_of", + "items": [ + { + "kind": "instance_of", + "type": { + "name": "FunctionScoreContainer", + "namespace": "_types.query_dsl" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "FunctionScoreContainer", + "namespace": "_types.query_dsl" + } + } } - } + ] } }, { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 0ec904e4a5..de63b2b306 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -6412,7 +6412,7 @@ export type QueryDslFunctionScoreMode = 'multiply' | 'sum' | 'avg' | 'first' | ' export interface QueryDslFunctionScoreQuery extends QueryDslQueryBase { boost_mode?: QueryDslFunctionBoostMode - functions?: QueryDslFunctionScoreContainer[] + functions?: QueryDslFunctionScoreContainer | QueryDslFunctionScoreContainer[] max_boost?: double min_score?: double query?: QueryDslQueryContainer @@ -6771,7 +6771,7 @@ export interface QueryDslQueryContainer { dis_max?: QueryDslDisMaxQuery distance_feature?: QueryDslDistanceFeatureQuery exists?: QueryDslExistsQuery - function_score?: QueryDslFunctionScoreQuery | QueryDslFunctionScoreContainer[] + function_score?: QueryDslFunctionScoreQuery | QueryDslFunctionScoreContainer | QueryDslFunctionScoreContainer[] fuzzy?: Partial> geo_bounding_box?: QueryDslGeoBoundingBoxQuery geo_distance?: QueryDslGeoDistanceQuery diff --git a/specification/_types/query_dsl/compound.ts b/specification/_types/query_dsl/compound.ts index 434f5918fc..1d08ab0a98 100644 --- a/specification/_types/query_dsl/compound.ts +++ b/specification/_types/query_dsl/compound.ts @@ -115,7 +115,7 @@ export class FunctionScoreQuery extends QueryBase { /** * One or more functions that compute a new score for each document returned by the query. */ - functions?: FunctionScoreContainer[] + functions?: FunctionScoreContainer | FunctionScoreContainer[] /** * Restricts the new score to not exceed the provided limit. */