From 6deaf541f8bf1978aaeda605b1881af7c5dd0e3a Mon Sep 17 00:00:00 2001 From: lcawl Date: Tue, 31 Dec 2024 21:23:20 -0800 Subject: [PATCH 1/3] Add search_application.render_query --- .../elasticsearch-openapi-overlays.yaml | 18 ++++- output/openapi/elasticsearch-openapi.json | 46 ++++++++++++ output/schema/schema.json | 71 +++++++++++++++++-- output/schema/validation-errors.json | 6 -- output/typescript/types.ts | 8 +++ specification/_doc_ids/table.csv | 1 + .../SearchApplicationsRenderQueryRequest.ts | 45 ++++++++++++ ...pplicationsRenderQueryRequestExample1.yaml | 12 ++++ .../SearchApplicationsRenderQueryResponse.ts | 22 ++++++ ...plicationsRenderQueryResponseExample1.yaml | 14 ++++ 10 files changed, 232 insertions(+), 11 deletions(-) create mode 100644 specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts create mode 100644 specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml create mode 100644 specification/search_application/render_query/SearchApplicationsRenderQueryResponse.ts create mode 100644 specification/search_application/render_query/SearchApplicationsRenderQueryResponseExample1.yaml diff --git a/docs/overlays/elasticsearch-openapi-overlays.yaml b/docs/overlays/elasticsearch-openapi-overlays.yaml index 502b6d2a18..5d77e1c965 100644 --- a/docs/overlays/elasticsearch-openapi-overlays.yaml +++ b/docs/overlays/elasticsearch-openapi-overlays.yaml @@ -391,4 +391,20 @@ actions: application/json: examples: indicesLegacyPutTemplateRequestExample1: - $ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml" \ No newline at end of file + $ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml" + - target: "$.paths['/_application/search_application/{name}/_render_query']['post']" + description: "Add examples for render search application query operation" + update: + requestBody: + content: + application/json: + examples: + renderSearchApplicationQueryRequestExample1: + $ref: "../../specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml" + responses: + 200: + content: + application/json: + examples: + renderSearchApplicationQueryResponseExample1: + $ref: "../../specification/search_application/render_query/SearchApplicationsRenderQueryResponseExample1.yaml" \ No newline at end of file diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 1278f6ef2d..e6f4e54c55 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -27176,6 +27176,52 @@ "x-beta": true } }, + "/_application/search_application/{name}/_render_query": { + "post": { + "tags": [ + "search_application" + ], + "summary": "Render a search application query", + "description": "Generate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.\nIf a parameter used in the search template is not specified in `params`, the parameter's default value will be used.\nThe API returns the specific Elasticsearch query that would be generated and run by calling the search application search API.\n\nYou must have `read` privileges on the backing alias of the search application.", + "operationId": "search-application-render-query", + "parameters": [ + { + "in": "path", + "name": "name", + "description": "The name of the search application to render teh query for.", + "required": true, + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:Name" + }, + "style": "simple" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/search_application._types:SearchApplicationParameters" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "x-state": "Technical preview" + } + }, "/_application/search_application/{name}/_search": { "get": { "tags": [ diff --git a/output/schema/schema.json b/output/schema/schema.json index ccd54f6e08..f738142ae7 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -15027,19 +15027,26 @@ { "availability": { "stack": { + "since": "8.9.0", "stability": "experimental", "visibility": "public" } }, - "description": "Renders a query for given search application search parameters", + "description": "Render a search application query.\nGenerate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.\nIf a parameter used in the search template is not specified in `params`, the parameter's default value will be used.\nThe API returns the specific Elasticsearch query that would be generated and run by calling the search application search API.\n\nYou must have `read` privileges on the backing alias of the search application.", "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-render-query.html", "name": "search_application.render_query", - "request": null, - "requestBodyRequired": false, + "request": { + "name": "Request", + "namespace": "search_application.render_query" + }, + "requestBodyRequired": true, "requestMediaType": [ "application/json" ], - "response": null, + "response": { + "name": "Response", + "namespace": "search_application.render_query" + }, "responseMediaType": [ "application/json" ], @@ -188971,6 +188978,62 @@ }, "specLocation": "search_application/put_behavioral_analytics/BehavioralAnalyticsPutResponse.ts#L23-L25" }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "value", + "codegenName": "search_application", + "value": { + "kind": "instance_of", + "type": { + "name": "SearchApplicationParameters", + "namespace": "search_application._types" + } + } + }, + "description": "Render a search application query.\nGenerate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.\nIf a parameter used in the search template is not specified in `params`, the parameter's default value will be used.\nThe API returns the specific Elasticsearch query that would be generated and run by calling the search application search API.\n\nYou must have `read` privileges on the backing alias of the search application.", + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "search_application.render_query" + }, + "path": [ + { + "description": "The name of the search application to render teh query for.", + "name": "name", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Name", + "namespace": "_types" + } + } + } + ], + "query": [], + "specLocation": "search_application/render_query/SearchApplicationsRenderQueryRequest.ts#L23-L45" + }, + { + "kind": "response", + "body": { + "kind": "properties", + "properties": [] + }, + "name": { + "name": "Response", + "namespace": "search_application.render_query" + }, + "specLocation": "search_application/render_query/SearchApplicationsRenderQueryResponse.ts#L20-L22" + }, { "kind": "request", "attachedBehaviors": [ diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index e5b3308da8..ccec040abd 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -623,12 +623,6 @@ ], "response": [] }, - "search_application.render_query": { - "request": [ - "Missing request & response" - ], - "response": [] - }, "search_mvt": { "request": [ "Request: query parameter 'grid_agg' does not exist in the json spec", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index f9d4f74893..62203159ce 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -17747,6 +17747,14 @@ export interface SearchApplicationPutBehavioralAnalyticsRequest extends RequestB export type SearchApplicationPutBehavioralAnalyticsResponse = SearchApplicationPutBehavioralAnalyticsAnalyticsAcknowledgeResponseBase +export interface SearchApplicationRenderQueryRequest extends RequestBase { + name: Name + body?: SearchApplicationSearchApplicationParameters +} + +export interface SearchApplicationRenderQueryResponse { +} + export interface SearchApplicationSearchRequest extends RequestBase { name: Name typed_keys?: boolean diff --git a/specification/_doc_ids/table.csv b/specification/_doc_ids/table.csv index f6a72b8fd7..28ec7b722c 100644 --- a/specification/_doc_ids/table.csv +++ b/specification/_doc_ids/table.csv @@ -541,6 +541,7 @@ search-aggregations-metrics-valuecount-aggregation,https://www.elastic.co/guide/ search-aggregations-metrics-weight-avg-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-metrics-weight-avg-aggregation.html search-aggregations-bucket-variablewidthhistogram-aggregation,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations-bucket-variablewidthhistogram-aggregation.html search-analyzer,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-analyzer.html +search-render-query,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-application-render-query.html search-count,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-count.html search-explain,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-explain.html search-field-caps,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-field-caps.html diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts new file mode 100644 index 0000000000..a076c287a3 --- /dev/null +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { RequestBase } from '@_types/Base' +import { Name } from '@_types/common' +import { SearchApplicationParameters } from '../_types/SearchApplicationParameters' + +/** + * Render a search application query. + * Generate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified. + * If a parameter used in the search template is not specified in `params`, the parameter's default value will be used. + * The API returns the specific Elasticsearch query that would be generated and run by calling the search application search API. + * + * You must have `read` privileges on the backing alias of the search application. + * @rest_spec_name search_application.render_query + * @availability stack since=8.9.0 stability=experimental visibility=public + */ +export interface Request extends RequestBase { + path_parts: { + /** + * The name of the search application to render teh query for. + */ + name: Name + } + /** + * Contains parameters for a search application. + */ + /** @codegen_name search_application */ + body: SearchApplicationParameters +} diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml b/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml new file mode 100644 index 0000000000..c0415d92c2 --- /dev/null +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml @@ -0,0 +1,12 @@ +# summary: +# method_request: POST _application/search_application/my-app/_render_query +# description: +# type: request +value: + params: + query_string: my first query + text_fields: + - name: title + boost: 5 + - name: description + boost: 1 diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryResponse.ts b/specification/search_application/render_query/SearchApplicationsRenderQueryResponse.ts new file mode 100644 index 0000000000..0769bf66cb --- /dev/null +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryResponse.ts @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export class Response { + body: {} +} diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryResponseExample1.yaml b/specification/search_application/render_query/SearchApplicationsRenderQueryResponseExample1.yaml new file mode 100644 index 0000000000..cc82fb06a1 --- /dev/null +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryResponseExample1.yaml @@ -0,0 +1,14 @@ +# summary: '' +description: A successful response for generating a query for a search application. The `from`, `size`, and `explain` parameters were not specified in the request, so the default values specified in the search template are used. +# type: response +# response_code: 200 +value: + from: 0 + size: 10 + query: + multi_match: + query: my first query + fields: + - 'description^1.0' + - 'title^5.0' + explain: false From ac34fa59db5c3ed08fae92e71ed9e1d74e007790 Mon Sep 17 00:00:00 2001 From: lcawl Date: Thu, 2 Jan 2025 20:35:42 -0800 Subject: [PATCH 2/3] Add doc_id --- docs/overlays/elasticsearch-openapi-overlays.yaml | 1 + output/schema/schema.json | 5 +++-- .../render_query/SearchApplicationsRenderQueryRequest.ts | 1 + .../SearchApplicationsRenderQueryRequestExample1.yaml | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/overlays/elasticsearch-openapi-overlays.yaml b/docs/overlays/elasticsearch-openapi-overlays.yaml index 5d77e1c965..4d9a8da6cd 100644 --- a/docs/overlays/elasticsearch-openapi-overlays.yaml +++ b/docs/overlays/elasticsearch-openapi-overlays.yaml @@ -392,6 +392,7 @@ actions: examples: indicesLegacyPutTemplateRequestExample1: $ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml" +## Examples for search applications - target: "$.paths['/_application/search_application/{name}/_render_query']['post']" description: "Add examples for render search application query operation" update: diff --git a/output/schema/schema.json b/output/schema/schema.json index 0fd10975fd..6f0d7b7eb1 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -15033,7 +15033,8 @@ } }, "description": "Render a search application query.\nGenerate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.\nIf a parameter used in the search template is not specified in `params`, the parameter's default value will be used.\nThe API returns the specific Elasticsearch query that would be generated and run by calling the search application search API.\n\nYou must have `read` privileges on the backing alias of the search application.", - "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-render-query.html", + "docId": "search-render-query", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-application-render-query.html", "name": "search_application.render_query", "request": { "name": "Request", @@ -189108,7 +189109,7 @@ } ], "query": [], - "specLocation": "search_application/render_query/SearchApplicationsRenderQueryRequest.ts#L23-L45" + "specLocation": "search_application/render_query/SearchApplicationsRenderQueryRequest.ts#L23-L46" }, { "kind": "response", diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts index a076c287a3..278e37cdf3 100644 --- a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts @@ -29,6 +29,7 @@ import { SearchApplicationParameters } from '../_types/SearchApplicationParamete * You must have `read` privileges on the backing alias of the search application. * @rest_spec_name search_application.render_query * @availability stack since=8.9.0 stability=experimental visibility=public + * @doc_id search-render-query */ export interface Request extends RequestBase { path_parts: { diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml b/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml index c0415d92c2..d76a54ab72 100644 --- a/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryRequestExample1.yaml @@ -1,6 +1,6 @@ # summary: # method_request: POST _application/search_application/my-app/_render_query -# description: +description: Run `POST _application/search_application/my-app/_render_query` to generate a query for a search application called `my-app` that uses the search template. # type: request value: params: From d2c86e84911b2e117db24308fc96ff28c65099e2 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 Jan 2025 10:13:29 +0400 Subject: [PATCH 3/3] Fix request body --- output/openapi/elasticsearch-openapi.json | 13 ++++++-- output/schema/schema.json | 32 +++++++++++++------ output/typescript/types.ts | 4 ++- .../SearchApplicationsRenderQueryRequest.ts | 8 +++-- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 3d8066fb73..0dd3baa93d 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -27201,11 +27201,18 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/search_application._types:SearchApplicationParameters" + "type": "object", + "properties": { + "params": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } } } - }, - "required": true + } }, "responses": { "200": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 6f0d7b7eb1..3962954221 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -15040,7 +15040,7 @@ "name": "Request", "namespace": "search_application.render_query" }, - "requestBodyRequired": true, + "requestBodyRequired": false, "requestMediaType": [ "application/json" ], @@ -189073,15 +189073,27 @@ "CommonQueryParameters" ], "body": { - "kind": "value", - "codegenName": "search_application", - "value": { - "kind": "instance_of", - "type": { - "name": "SearchApplicationParameters", - "namespace": "search_application._types" + "kind": "properties", + "properties": [ + { + "name": "params", + "required": false, + "type": { + "kind": "dictionary_of", + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + "singleKey": false, + "value": { + "kind": "user_defined_value" + } + } } - } + ] }, "description": "Render a search application query.\nGenerate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.\nIf a parameter used in the search template is not specified in `params`, the parameter's default value will be used.\nThe API returns the specific Elasticsearch query that would be generated and run by calling the search application search API.\n\nYou must have `read` privileges on the backing alias of the search application.", "inherits": { @@ -189109,7 +189121,7 @@ } ], "query": [], - "specLocation": "search_application/render_query/SearchApplicationsRenderQueryRequest.ts#L23-L46" + "specLocation": "search_application/render_query/SearchApplicationsRenderQueryRequest.ts#L24-L48" }, { "kind": "response", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 2a070529e0..a9bcfd2566 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -17756,7 +17756,9 @@ export type SearchApplicationPutBehavioralAnalyticsResponse = SearchApplicationP export interface SearchApplicationRenderQueryRequest extends RequestBase { name: Name - body?: SearchApplicationSearchApplicationParameters + body?: { + params?: Record + } } export interface SearchApplicationRenderQueryResponse { diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts index 278e37cdf3..d9255b8bf8 100644 --- a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts @@ -16,9 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +import { Dictionary } from '@spec_utils/Dictionary' +import { UserDefinedValue } from '@spec_utils/UserDefinedValue' import { RequestBase } from '@_types/Base' import { Name } from '@_types/common' -import { SearchApplicationParameters } from '../_types/SearchApplicationParameters' /** * Render a search application query. @@ -41,6 +42,7 @@ export interface Request extends RequestBase { /** * Contains parameters for a search application. */ - /** @codegen_name search_application */ - body: SearchApplicationParameters + body: { + params?: Dictionary + } }