diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index c9ef99a1a..ed0ac8f9f 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -7020,7 +7020,7 @@ Creates or updates a query ruleset. {ref}/put-query-ruleset.html[Endpoint documentation] [source,ts] ---- -client.queryRuleset.put({ ruleset_id }) +client.queryRuleset.put({ ruleset_id, rules }) ---- [discrete] @@ -7028,7 +7028,7 @@ client.queryRuleset.put({ ruleset_id }) * *Request (object):* ** *`ruleset_id` (string)*: The unique identifier of the query ruleset to be created or updated -** *`query_ruleset` (Optional, { ruleset_id, rules })* +** *`rules` ({ rule_id, type, criteria, actions }[])* [discrete] === rollup diff --git a/src/api/api/query_ruleset.ts b/src/api/api/query_ruleset.ts index 01ee774ae..771205b0e 100644 --- a/src/api/api/query_ruleset.ts +++ b/src/api/api/query_ruleset.ts @@ -131,15 +131,22 @@ export default class QueryRuleset { async put (this: That, params: T.QueryRulesetPutRequest | TB.QueryRulesetPutRequest, options?: TransportRequestOptions): Promise async put (this: That, params: T.QueryRulesetPutRequest | TB.QueryRulesetPutRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['ruleset_id'] - const acceptedBody: string[] = ['query_ruleset'] + const acceptedBody: string[] = ['rules'] const querystring: Record = {} // @ts-expect-error - let body: any = params.body ?? undefined + const userBody: any = params?.body + let body: Record | string + if (typeof userBody === 'string') { + body = userBody + } else { + body = userBody != null ? { ...userBody } : undefined + } for (const key in params) { if (acceptedBody.includes(key)) { + body = body ?? {} // @ts-expect-error - body = params[key] + body[key] = params[key] } else if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { diff --git a/src/api/types.ts b/src/api/types.ts index cb43fd81e..bb6172874 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -3240,8 +3240,8 @@ export type AggregationsFrequentItemSetsBucket = AggregationsFrequentItemSetsBuc export interface AggregationsFrequentItemSetsField { field: Field - exclude?: string | string[] - include?: string | string[] + exclude?: AggregationsTermsExclude + include?: AggregationsTermsInclude } export type AggregationsGapPolicy = 'skip' | 'insert_zeros' | 'keep_values' @@ -3856,7 +3856,7 @@ export interface AggregationsSignificantTextAggregation extends AggregationsBuck field?: Field filter_duplicate_text?: boolean gnd?: AggregationsGoogleNormalizedDistanceHeuristic - include?: string | string[] + include?: AggregationsTermsInclude jlh?: EmptyObject min_doc_count?: long mutual_information?: AggregationsMutualInformationHeuristic @@ -15279,7 +15279,7 @@ export interface QueryRulesetListResponse { export interface QueryRulesetPutRequest extends RequestBase { ruleset_id: Id - query_ruleset?: QueryRulesetQueryRuleset + rules: QueryRulesetQueryRule[] } export interface QueryRulesetPutResponse { diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index c97c43834..9baaacbc2 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -3313,8 +3313,8 @@ export type AggregationsFrequentItemSetsBucket = AggregationsFrequentItemSetsBuc export interface AggregationsFrequentItemSetsField { field: Field - exclude?: string | string[] - include?: string | string[] + exclude?: AggregationsTermsExclude + include?: AggregationsTermsInclude } export type AggregationsGapPolicy = 'skip' | 'insert_zeros' | 'keep_values' @@ -3929,7 +3929,7 @@ export interface AggregationsSignificantTextAggregation extends AggregationsBuck field?: Field filter_duplicate_text?: boolean gnd?: AggregationsGoogleNormalizedDistanceHeuristic - include?: string | string[] + include?: AggregationsTermsInclude jlh?: EmptyObject min_doc_count?: long mutual_information?: AggregationsMutualInformationHeuristic @@ -15574,8 +15574,10 @@ export interface QueryRulesetListResponse { export interface QueryRulesetPutRequest extends RequestBase { ruleset_id: Id - /** @deprecated The use of the 'body' key has been deprecated, use 'query_ruleset' instead. */ - body?: QueryRulesetQueryRuleset + /** @deprecated The use of the 'body' key has been deprecated, move the nested keys to the top level object. */ + body?: { + rules: QueryRulesetQueryRule[] + } } export interface QueryRulesetPutResponse {