From 88bcaaa8e64fb0803414a9fa0d056a1cac5d81b6 Mon Sep 17 00:00:00 2001 From: Matteo Piergiovanni <134913285+piergm@users.noreply.github.com> Date: Mon, 12 Feb 2024 11:13:58 +0100 Subject: [PATCH] Add optional query param in _field_caps to return only fields with value in index (#2413) --- .../elasticsearch-serverless-openapi.json | 22 +++++++++++++++++++ output/schema/schema.json | 22 ++++++++++++++++++- output/typescript/types.ts | 1 + .../field_caps/FieldCapabilitiesRequest.ts | 7 ++++++ specification/_json_spec/field_caps.json | 5 +++++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index be4b736b06..1332f7a446 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -4229,6 +4229,9 @@ }, { "$ref": "#/components/parameters/field_caps#types" + }, + { + "$ref": "#/components/parameters/field_caps#include_empty_fields" } ], "requestBody": { @@ -4271,6 +4274,9 @@ }, { "$ref": "#/components/parameters/field_caps#types" + }, + { + "$ref": "#/components/parameters/field_caps#include_empty_fields" } ], "requestBody": { @@ -4318,6 +4324,9 @@ }, { "$ref": "#/components/parameters/field_caps#types" + }, + { + "$ref": "#/components/parameters/field_caps#include_empty_fields" } ], "requestBody": { @@ -4363,6 +4372,9 @@ }, { "$ref": "#/components/parameters/field_caps#types" + }, + { + "$ref": "#/components/parameters/field_caps#include_empty_fields" } ], "requestBody": { @@ -21921,6 +21933,16 @@ }, "style": "form" }, + "field_caps#include_empty_fields": { + "in": "query", + "name": "include_empty_fields", + "description": "If false, empty fields are not included in the response.", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" + }, "graph.explore#index": { "in": "path", "name": "index", diff --git a/output/schema/schema.json b/output/schema/schema.json index d8f4dd8778..79a2c416dd 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -23232,9 +23232,29 @@ } } } + }, + { + "availability": { + "serverless": {}, + "stack": { + "since": "8.13.0" + } + }, + "description": "If false, empty fields are not included in the response.", + "name": "include_empty_fields", + "required": false, + "serverDefault": true, + "since": "8.13.0", + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } } ], - "specLocation": "_global/field_caps/FieldCapabilitiesRequest.ts#L25-L99" + "specLocation": "_global/field_caps/FieldCapabilitiesRequest.ts#L25-L106" }, { "body": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 4332c5c735..78ea2b237b 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -349,6 +349,7 @@ export interface FieldCapsRequest extends RequestBase { include_unmapped?: boolean filters?: string types?: string[] + include_empty_fields?: boolean body?: { fields?: Fields index_filter?: QueryDslQueryContainer diff --git a/specification/_global/field_caps/FieldCapabilitiesRequest.ts b/specification/_global/field_caps/FieldCapabilitiesRequest.ts index 621397d5d7..5952cfb181 100644 --- a/specification/_global/field_caps/FieldCapabilitiesRequest.ts +++ b/specification/_global/field_caps/FieldCapabilitiesRequest.ts @@ -75,6 +75,13 @@ export interface Request extends RequestBase { * @availability serverless */ types?: string[] + /** + * If false, empty fields are not included in the response. + * @availability stack since=8.13.0 + * @availability serverless + * @server_default true + */ + include_empty_fields?: boolean } body: { /** diff --git a/specification/_json_spec/field_caps.json b/specification/_json_spec/field_caps.json index ba5e8e9cd9..0460579608 100644 --- a/specification/_json_spec/field_caps.json +++ b/specification/_json_spec/field_caps.json @@ -59,6 +59,11 @@ "types": { "type": "list", "description": "Only return results for fields that have one of the types in the list" + }, + "include_empty_fields": { + "type": "boolean", + "default": true, + "description": "Indicates whether empty fields should be included in the response." } }, "body": {