From 89bb2bf0e4610e341cbac38942a8d44187be3daa Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 6 Nov 2023 11:41:04 +0400 Subject: [PATCH] Allow single fields in fields and _source parameters (#2317) (cherry picked from commit 9f40be8b64f80a8602c362aae25ff27be71e1b9a) --- output/schema/schema.json | 108 +++++++++++++----- output/typescript/types.ts | 10 +- specification/_global/msearch/types.ts | 5 +- specification/_global/search/SearchRequest.ts | 4 +- .../_global/search/_types/SourceFilter.ts | 4 +- 5 files changed, 94 insertions(+), 37 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index 5520cc1d0f..c9043c13fc 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -26213,7 +26213,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L214-L217" + "specLocation": "_global/msearch/types.ts#L215-L218" }, { "generics": [ @@ -26263,7 +26263,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L204-L207" + "specLocation": "_global/msearch/types.ts#L205-L208" }, { "kind": "interface", @@ -26371,11 +26371,23 @@ "type": { "kind": "array_of", "value": { - "kind": "instance_of", - "type": { - "name": "FieldAndFormat", - "namespace": "_types.query_dsl" - } + "items": [ + { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + }, + { + "kind": "instance_of", + "type": { + "name": "FieldAndFormat", + "namespace": "_types.query_dsl" + } + } + ], + "kind": "union_of" } } }, @@ -26602,11 +26614,23 @@ "type": { "kind": "array_of", "value": { - "kind": "instance_of", - "type": { - "name": "FieldAndFormat", - "namespace": "_types.query_dsl" - } + "items": [ + { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + }, + { + "kind": "instance_of", + "type": { + "name": "FieldAndFormat", + "namespace": "_types.query_dsl" + } + } + ], + "kind": "union_of" } } }, @@ -26736,7 +26760,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L71-L202" + "specLocation": "_global/msearch/types.ts#L72-L203" }, { "description": "Contains parameters used to limit or change the subsequent search body request.", @@ -26868,7 +26892,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L53-L68" + "specLocation": "_global/msearch/types.ts#L54-L69" }, { "attachedBehaviors": [ @@ -27079,7 +27103,7 @@ "name": "RequestItem", "namespace": "_global.msearch" }, - "specLocation": "_global/msearch/types.ts#L48-L51", + "specLocation": "_global/msearch/types.ts#L49-L52", "type": { "items": [ { @@ -27149,7 +27173,7 @@ "name": "ResponseItem", "namespace": "_global.msearch" }, - "specLocation": "_global/msearch/types.ts#L209-L212", + "specLocation": "_global/msearch/types.ts#L210-L213", "type": { "items": [ { @@ -30676,11 +30700,23 @@ "type": { "kind": "array_of", "value": { - "kind": "instance_of", - "type": { - "name": "FieldAndFormat", - "namespace": "_types.query_dsl" - } + "items": [ + { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + }, + { + "kind": "instance_of", + "type": { + "name": "FieldAndFormat", + "namespace": "_types.query_dsl" + } + } + ], + "kind": "union_of" } } }, @@ -30906,11 +30942,23 @@ "type": { "kind": "array_of", "value": { - "kind": "instance_of", - "type": { - "name": "FieldAndFormat", - "namespace": "_types.query_dsl" - } + "items": [ + { + "kind": "instance_of", + "type": { + "name": "FieldAndFormat", + "namespace": "_types.query_dsl" + } + }, + { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + } + ], + "kind": "union_of" } } }, @@ -35779,6 +35827,7 @@ { "codegenNames": [ "fetch", + "fields", "filter" ], "description": "Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.", @@ -35797,6 +35846,13 @@ "namespace": "_builtins" } }, + { + "kind": "instance_of", + "type": { + "name": "Fields", + "namespace": "_types" + } + }, { "kind": "instance_of", "type": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index c3541c3766..c601312b12 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -728,7 +728,7 @@ export interface MsearchMultisearchBody { explain?: boolean ext?: Record stored_fields?: Fields - docvalue_fields?: (QueryDslFieldAndFormat | Field)[] + docvalue_fields?: (Field | QueryDslFieldAndFormat | Field)[] knn?: KnnQuery | KnnQuery[] from?: integer highlight?: SearchHighlight @@ -742,7 +742,7 @@ export interface MsearchMultisearchBody { size?: integer sort?: Sort _source?: SearchSourceConfig - fields?: (QueryDslFieldAndFormat | Field)[] + fields?: (Field | QueryDslFieldAndFormat | Field)[] terminate_after?: long stats?: string[] timeout?: string @@ -1194,7 +1194,7 @@ export interface SearchRequest extends RequestBase { highlight?: SearchHighlight track_total_hits?: SearchTrackHits indices_boost?: Record[] - docvalue_fields?: (QueryDslFieldAndFormat | Field)[] + docvalue_fields?: (Field | QueryDslFieldAndFormat | Field)[] knn?: KnnQuery | KnnQuery[] rank?: RankContainer min_score?: double @@ -1208,7 +1208,7 @@ export interface SearchRequest extends RequestBase { slice?: SlicedScroll sort?: Sort _source?: SearchSourceConfig - fields?: (QueryDslFieldAndFormat | Field)[] + fields?: (QueryDslFieldAndFormat | Field | Field)[] suggest?: SearchSuggester terminate_after?: long timeout?: string @@ -1632,7 +1632,7 @@ export interface SearchSmoothingModelContainer { stupid_backoff?: SearchStupidBackoffSmoothingModel } -export type SearchSourceConfig = boolean | SearchSourceFilter | Fields +export type SearchSourceConfig = boolean | Fields | SearchSourceFilter | Fields export type SearchSourceConfigParam = boolean | Fields diff --git a/specification/_global/msearch/types.ts b/specification/_global/msearch/types.ts index 46934beba4..47c382d1b9 100644 --- a/specification/_global/msearch/types.ts +++ b/specification/_global/msearch/types.ts @@ -23,6 +23,7 @@ import { Dictionary } from '@spec_utils/Dictionary' import { AggregationContainer } from '@_types/aggregations/AggregationContainer' import { ExpandWildcards, + Field, Fields, IndexName, Indices, @@ -96,7 +97,7 @@ export class MultisearchBody { * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. */ - docvalue_fields?: FieldAndFormat[] + docvalue_fields?: Array /** * Defines the approximate kNN search to run. * @availability stack since=8.4.0 @@ -146,7 +147,7 @@ export class MultisearchBody { * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. */ - fields?: Array + fields?: Array /** * Maximum number of documents to collect for each shard. If a query reaches this * limit, Elasticsearch terminates the query early. Elasticsearch collects documents diff --git a/specification/_global/search/SearchRequest.ts b/specification/_global/search/SearchRequest.ts index 2ef86e22a0..bdbf484422 100644 --- a/specification/_global/search/SearchRequest.ts +++ b/specification/_global/search/SearchRequest.ts @@ -371,7 +371,7 @@ export interface Request extends RequestBase { * Array of wildcard (`*`) patterns. * The request returns doc values for field names matching these patterns in the `hits.fields` property of the response. */ - docvalue_fields?: FieldAndFormat[] + docvalue_fields?: Array /** * Defines the approximate kNN search to run. * @availability stack since=8.4.0 @@ -442,7 +442,7 @@ export interface Request extends RequestBase { * Array of wildcard (`*`) patterns. * The request returns values for field names matching these patterns in the `hits.fields` property of the response. */ - fields?: Array + fields?: Array /** * Defines a suggester that provides similar looking terms based on a provided text. */ diff --git a/specification/_global/search/_types/SourceFilter.ts b/specification/_global/search/_types/SourceFilter.ts index 6b48c59f79..b2b2c05071 100644 --- a/specification/_global/search/_types/SourceFilter.ts +++ b/specification/_global/search/_types/SourceFilter.ts @@ -32,9 +32,9 @@ export class SourceFilter { /** * Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered. - * @codegen_names fetch, filter + * @codegen_names fetch, fields, filter */ -export type SourceConfig = boolean | SourceFilter +export type SourceConfig = boolean | Fields | SourceFilter /** * Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.