Skip to content

Add search_application.render_query #3401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/overlays/elasticsearch-openapi-overlays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,21 @@ actions:
application/json:
examples:
indicesLegacyPutTemplateRequestExample1:
$ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml"
$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:
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"
53 changes: 53 additions & 0 deletions output/openapi/elasticsearch-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 80 additions & 4 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions output/schema/validation-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions specification/_doc_ids/table.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 { Dictionary } from '@spec_utils/Dictionary'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
import { RequestBase } from '@_types/Base'
import { Name } from '@_types/common'

/**
* 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
* @doc_id search-render-query
*/
export interface Request extends RequestBase {
path_parts: {
/**
* The name of the search application to render teh query for.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: the

*/
name: Name
}
/**
* Contains parameters for a search application.
*/
body: {
params?: Dictionary<string, UserDefinedValue>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# summary:
# method_request: POST _application/search_application/my-app/_render_query
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:
query_string: my first query
text_fields:
- name: title
boost: 5
- name: description
boost: 1
Original file line number Diff line number Diff line change
@@ -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: {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Do we somewhere track these cases where we only defined a request, but not a proper response?

Doing it like this will suppress the compiler warning about missing request/response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Does this mean it's preferable to omit the response file entirely when we don't know the contents of the body?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it like this will suppress the compiler warning about missing request/response.

I'm also surprised that make validate passed, which is why I did not realize that the body was missing.

Good point. Does this mean it's preferable to omit the response file entirely when we don't know the contents of the body?

Ideally, yes, but it breaks the OpenAPI transformation right now.

}
Original file line number Diff line number Diff line change
@@ -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
Loading