diff --git a/output/schema/schema.json b/output/schema/schema.json index 3cbc4dae14..c8a1d6a31d 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -76527,7 +76527,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L196-L196" + "specLocation": "_types/query_dsl/compound.ts#L201-L201" }, { "kind": "interface", @@ -76621,7 +76621,7 @@ "name": "DecayFunction", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L202-L211", + "specLocation": "_types/query_dsl/compound.ts#L207-L216", "type": { "kind": "union_of", "items": [ @@ -76741,7 +76741,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L178-L189" + "specLocation": "_types/query_dsl/compound.ts#L183-L194" }, { "kind": "interface", @@ -76811,7 +76811,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L157-L176" + "specLocation": "_types/query_dsl/compound.ts#L162-L181" }, { "kind": "interface", @@ -77146,7 +77146,7 @@ "name": "FieldValueFactorModifier", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L310-L353" + "specLocation": "_types/query_dsl/compound.ts#L348-L391" }, { "kind": "interface", @@ -77205,7 +77205,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L136-L155" + "specLocation": "_types/query_dsl/compound.ts#L141-L160" }, { "kind": "enum", @@ -77239,7 +77239,38 @@ "name": "FunctionBoostMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L282-L308" + "specLocation": "_types/query_dsl/compound.ts#L320-L346" + }, + { + "kind": "type_alias", + "codegenNames": [ + "single", + "multi" + ], + "name": { + "name": "FunctionScore", + "namespace": "_types.query_dsl" + }, + "specLocation": "_types/query_dsl/compound.ts#L93-L94", + "type": { + "kind": "union_of", + "items": [ + { + "kind": "instance_of", + "type": { + "name": "SingleFunctionScoreContainer", + "namespace": "_types.query_dsl" + } + }, + { + "kind": "instance_of", + "type": { + "name": "MultiFunctionScoreQuery", + "namespace": "_types.query_dsl" + } + } + ] + } }, { "kind": "interface", @@ -77346,7 +77377,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L213-L253", + "specLocation": "_types/query_dsl/compound.ts#L218-L258", "variants": { "kind": "container" } @@ -77383,101 +77414,7 @@ "name": "FunctionScoreMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L255-L280" - }, - { - "kind": "interface", - "inherits": { - "type": { - "name": "QueryBase", - "namespace": "_types.query_dsl" - } - }, - "name": { - "name": "FunctionScoreQuery", - "namespace": "_types.query_dsl" - }, - "properties": [ - { - "description": "Defines how he newly computed score is combined with the score of the query", - "name": "boost_mode", - "required": false, - "serverDefault": "multiply", - "type": { - "kind": "instance_of", - "type": { - "name": "FunctionBoostMode", - "namespace": "_types.query_dsl" - } - } - }, - { - "description": "One or more functions that compute a new score for each document returned by the query.", - "name": "functions", - "required": false, - "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "FunctionScoreContainer", - "namespace": "_types.query_dsl" - } - } - } - }, - { - "description": "Restricts the new score to not exceed the provided limit.", - "name": "max_boost", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "double", - "namespace": "_types" - } - } - }, - { - "description": "Excludes documents that do not meet the provided score threshold.", - "name": "min_score", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "double", - "namespace": "_types" - } - } - }, - { - "description": "A query that determines the documents for which a new score is computed.", - "name": "query", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "QueryContainer", - "namespace": "_types.query_dsl" - } - } - }, - { - "description": "Specifies how the computed scores are combined", - "name": "score_mode", - "required": false, - "serverDefault": "multiply", - "type": { - "kind": "instance_of", - "type": { - "name": "FunctionScoreMode", - "namespace": "_types.query_dsl" - } - } - } - ], - "shortcutProperty": "functions", - "specLocation": "_types/query_dsl/compound.ts#L93-L122" + "specLocation": "_types/query_dsl/compound.ts#L293-L318" }, { "kind": "interface", @@ -77715,7 +77652,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L197-L200" + "specLocation": "_types/query_dsl/compound.ts#L202-L205" }, { "kind": "interface", @@ -79917,6 +79854,100 @@ ], "specLocation": "_types/query_dsl/specialized.ts#L87-L169" }, + { + "kind": "interface", + "inherits": { + "type": { + "name": "QueryBase", + "namespace": "_types.query_dsl" + } + }, + "name": { + "name": "MultiFunctionScoreQuery", + "namespace": "_types.query_dsl" + }, + "properties": [ + { + "description": "One or more functions that compute a new score for each document returned by the query.", + "name": "functions", + "required": false, + "type": { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "FunctionScoreContainer", + "namespace": "_types.query_dsl" + } + } + } + }, + { + "description": "Defines how he newly computed score is combined with the score of the query", + "name": "boost_mode", + "required": false, + "serverDefault": "multiply", + "type": { + "kind": "instance_of", + "type": { + "name": "FunctionBoostMode", + "namespace": "_types.query_dsl" + } + } + }, + { + "description": "Restricts the new score to not exceed the provided limit.", + "name": "max_boost", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } + }, + { + "description": "Excludes documents that do not meet the provided score threshold.", + "name": "min_score", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } + }, + { + "description": "A query that determines the documents for which a new score is computed.", + "name": "query", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "QueryContainer", + "namespace": "_types.query_dsl" + } + } + }, + { + "description": "Specifies how the computed scores are combined", + "name": "score_mode", + "required": false, + "serverDefault": "multiply", + "type": { + "kind": "instance_of", + "type": { + "name": "FunctionScoreMode", + "namespace": "_types.query_dsl" + } + } + } + ], + "shortcutProperty": "functions", + "specLocation": "_types/query_dsl/compound.ts#L96-L127" + }, { "kind": "interface", "inherits": { @@ -80182,7 +80213,7 @@ "name": "MultiValueMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L355-L372" + "specLocation": "_types/query_dsl/compound.ts#L393-L410" }, { "kind": "interface", @@ -80320,7 +80351,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L195-L195" + "specLocation": "_types/query_dsl/compound.ts#L200-L200" }, { "kind": "enum", @@ -80857,7 +80888,7 @@ "type": { "kind": "instance_of", "type": { - "name": "FunctionScoreQuery", + "name": "FunctionScore", "namespace": "_types.query_dsl" } } @@ -82158,7 +82189,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L131-L134" + "specLocation": "_types/query_dsl/compound.ts#L136-L139" }, { "kind": "type_alias", @@ -82748,7 +82779,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L124-L129" + "specLocation": "_types/query_dsl/compound.ts#L129-L134" }, { "kind": "interface", @@ -83222,6 +83253,92 @@ ], "specLocation": "_types/query_dsl/fulltext.ts#L765-L830" }, + { + "kind": "interface", + "inherits": { + "type": { + "name": "FunctionScoreContainer", + "namespace": "_types.query_dsl" + } + }, + "name": { + "name": "SingleFunctionScoreContainer", + "namespace": "_types.query_dsl" + }, + "properties": [ + { + "containerProperty": true, + "description": "Defines how he newly computed score is combined with the score of the query", + "name": "boost_mode", + "required": false, + "serverDefault": "multiply", + "type": { + "kind": "instance_of", + "type": { + "name": "FunctionBoostMode", + "namespace": "_types.query_dsl" + } + } + }, + { + "containerProperty": true, + "description": "Restricts the new score to not exceed the provided limit.", + "name": "max_boost", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } + }, + { + "containerProperty": true, + "description": "Excludes documents that do not meet the provided score threshold.", + "name": "min_score", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } + }, + { + "containerProperty": true, + "description": "A query that determines the documents for which a new score is computed.", + "name": "query", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "QueryContainer", + "namespace": "_types.query_dsl" + } + } + }, + { + "containerProperty": true, + "description": "Specifies how the computed scores are combined", + "name": "score_mode", + "required": false, + "serverDefault": "multiply", + "type": { + "kind": "instance_of", + "type": { + "name": "FunctionScoreMode", + "namespace": "_types.query_dsl" + } + } + } + ], + "specLocation": "_types/query_dsl/compound.ts#L260-L291", + "variants": { + "kind": "container" + } + }, { "kind": "interface", "inherits": { @@ -84351,7 +84468,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L191-L194" + "specLocation": "_types/query_dsl/compound.ts#L196-L199" }, { "kind": "interface", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 3ed53d7b75..02f05aa3db 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -5833,6 +5833,8 @@ export interface QueryDslFieldValueFactorScoreFunction { export type QueryDslFunctionBoostMode = 'multiply' | 'replace' | 'sum' | 'avg' | 'max' | 'min' +export type QueryDslFunctionScore = QueryDslSingleFunctionScoreContainer | QueryDslMultiFunctionScoreQuery | QueryDslFunctionScoreContainer[] + export interface QueryDslFunctionScoreContainer { exp?: QueryDslDecayFunction gauss?: QueryDslDecayFunction @@ -5846,15 +5848,6 @@ export interface QueryDslFunctionScoreContainer { export type QueryDslFunctionScoreMode = 'multiply' | 'sum' | 'avg' | 'first' | 'max' | 'min' -export interface QueryDslFunctionScoreQuery extends QueryDslQueryBase { - boost_mode?: QueryDslFunctionBoostMode - functions?: QueryDslFunctionScoreContainer[] - max_boost?: double - min_score?: double - query?: QueryDslQueryContainer - score_mode?: QueryDslFunctionScoreMode -} - export interface QueryDslFuzzyQuery extends QueryDslQueryBase { max_expansions?: integer prefix_length?: integer @@ -6093,6 +6086,15 @@ export interface QueryDslMoreLikeThisQuery extends QueryDslQueryBase { version_type?: VersionType } +export interface QueryDslMultiFunctionScoreQuery extends QueryDslQueryBase { + functions?: QueryDslFunctionScoreContainer[] + boost_mode?: QueryDslFunctionBoostMode + max_boost?: double + min_score?: double + query?: QueryDslQueryContainer + score_mode?: QueryDslFunctionScoreMode +} + export interface QueryDslMultiMatchQuery extends QueryDslQueryBase { analyzer?: string auto_generate_synonyms_phrase_query?: boolean @@ -6182,7 +6184,7 @@ export interface QueryDslQueryContainer { dis_max?: QueryDslDisMaxQuery distance_feature?: QueryDslDistanceFeatureQuery exists?: QueryDslExistsQuery - function_score?: QueryDslFunctionScoreQuery | QueryDslFunctionScoreContainer[] + function_score?: QueryDslFunctionScore fuzzy?: Partial> geo_bounding_box?: QueryDslGeoBoundingBoxQuery geo_distance?: QueryDslGeoDistanceQuery @@ -6377,6 +6379,14 @@ export interface QueryDslSimpleQueryStringQuery extends QueryDslQueryBase { quote_field_suffix?: string } +export interface QueryDslSingleFunctionScoreContainer extends QueryDslFunctionScoreContainer { + boost_mode?: QueryDslFunctionBoostMode + max_boost?: double + min_score?: double + query?: QueryDslQueryContainer + score_mode?: QueryDslFunctionScoreMode +} + export interface QueryDslSpanContainingQuery extends QueryDslQueryBase { big: QueryDslSpanQuery little: QueryDslSpanQuery diff --git a/specification/_types/query_dsl/abstractions.ts b/specification/_types/query_dsl/abstractions.ts index 67f3b32122..7287dc2c73 100644 --- a/specification/_types/query_dsl/abstractions.ts +++ b/specification/_types/query_dsl/abstractions.ts @@ -31,7 +31,7 @@ import { BoostingQuery, ConstantScoreQuery, DisMaxQuery, - FunctionScoreQuery + FunctionScore } from './compound' import { CommonTermsQuery, @@ -150,7 +150,7 @@ export class QueryContainer { * The `function_score` enables you to modify the score of documents that are retrieved by a query. * @doc_id query-dsl-function-score-query */ - function_score?: FunctionScoreQuery + function_score?: FunctionScore /** * Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance. * @doc_id query-dsl-fuzzy-query diff --git a/specification/_types/query_dsl/compound.ts b/specification/_types/query_dsl/compound.ts index 2bd27b9e81..2d779d35a3 100644 --- a/specification/_types/query_dsl/compound.ts +++ b/specification/_types/query_dsl/compound.ts @@ -90,19 +90,26 @@ export class DisMaxQuery extends QueryBase { tie_breaker?: double } +/** @codegen_names single, multi */ +export type FunctionScore = + | SingleFunctionScoreContainer + | MultiFunctionScoreQuery + /** * @shortcut_property functions */ -export class FunctionScoreQuery extends QueryBase { +export class MultiFunctionScoreQuery extends QueryBase { + /** + * One or more functions that compute a new score for each document returned by the query. + */ + functions?: FunctionScoreContainer[] + + // WARNING: keep below properties in sync with SingleFunctionScoreContainer /** * Defines how he newly computed score is combined with the score of the query * @server_default multiply */ boost_mode?: FunctionBoostMode - /** - * One or more functions that compute a new score for each document returned by the query. - */ - functions?: FunctionScoreContainer[] /** * Restricts the new score to not exceed the provided limit. */ @@ -252,6 +259,39 @@ export class FunctionScoreContainer { weight?: double } +/** + * @variants container + */ +export class SingleFunctionScoreContainer extends FunctionScoreContainer { + // WARNING: keep below properties in sync with MultiFunctionScoreQuery + /** + * Defines how he newly computed score is combined with the score of the query + * @server_default multiply + * @variant container_property + */ + boost_mode?: FunctionBoostMode + /** + * Restricts the new score to not exceed the provided limit. + * @variant container_property + */ + max_boost?: double + /** + * Excludes documents that do not meet the provided score threshold. + * @variant container_property + */ + min_score?: double + /** + * A query that determines the documents for which a new score is computed. + * @variant container_property + */ + query?: QueryContainer + /** Specifies how the computed scores are combined + * @server_default multiply + * @variant container_property + */ + score_mode?: FunctionScoreMode +} + export enum FunctionScoreMode { /** * Scores are multiplied.