From c4d579b5b9e5df60544c724a249b30d658cf0d02 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 43bab19669..7c2814f338 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -25919,7 +25919,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L214-L217" + "specLocation": "_global/msearch/types.ts#L215-L218" }, { "generics": [ @@ -25969,7 +25969,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L204-L207" + "specLocation": "_global/msearch/types.ts#L205-L208" }, { "kind": "interface", @@ -26077,11 +26077,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" } } }, @@ -26308,11 +26320,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" } } }, @@ -26442,7 +26466,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.", @@ -26574,7 +26598,7 @@ } } ], - "specLocation": "_global/msearch/types.ts#L53-L68" + "specLocation": "_global/msearch/types.ts#L54-L69" }, { "attachedBehaviors": [ @@ -26785,7 +26809,7 @@ "name": "RequestItem", "namespace": "_global.msearch" }, - "specLocation": "_global/msearch/types.ts#L48-L51", + "specLocation": "_global/msearch/types.ts#L49-L52", "type": { "items": [ { @@ -26855,7 +26879,7 @@ "name": "ResponseItem", "namespace": "_global.msearch" }, - "specLocation": "_global/msearch/types.ts#L209-L212", + "specLocation": "_global/msearch/types.ts#L210-L213", "type": { "items": [ { @@ -30289,11 +30313,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" } } }, @@ -30519,11 +30555,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" } } }, @@ -35325,6 +35373,7 @@ { "codegenNames": [ "fetch", + "fields", "filter" ], "description": "Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.", @@ -35343,6 +35392,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 7b7c8777ec..aab0406d8a 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.