Skip to content
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

Index Search Template API tests #702

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `s` to `/_ingest/processor/grok` ([#689](https://github.com/opensearch-project/opensearch-api-specification/pull/689))
- Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
- Added `aggregations` to `/nodes/_usage/{metric}` requests and responses ([#615](https://github.com/opensearch-project/opensearch-api-specification/pull/615))
- Added missing `status` to `/_search/template` response([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702))

### Removed
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
Expand Down
2 changes: 2 additions & 0 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3266,6 +3266,8 @@ components:
$ref: '../schemas/_core.search.yaml#/components/schemas/Suggest'
terminated_early:
type: boolean
status:
Tokesh marked this conversation as resolved.
Show resolved Hide resolved
type: number
required:
- _shards
- hits
Expand Down
95 changes: 95 additions & 0 deletions tests/default/indices/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test search with templates using both index-specific and global endpoints via GET and POST methods.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: movies, _id: movie1}}
- {director: Quentin Tarantino, title: Pulp Fiction, year: 1994}
- {create: {_index: movies, _id: movie2}}
- {director: Christopher Nolan, title: Inception, year: 2010}
- path: /_scripts/movie_template
method: POST
request:
content_type: application/json
payload:
script:
lang: mustache
source: >
{
"query": {
"match": {
"{{field}}": "{{value}}"
}
}
}

chapters:
- synopsis: Perform a global search using a template with GET.
path: /_search/template
method: GET
request:
payload:
id: movie_template
params:
field:
value: year
value:
value: 1994
response:
status: 200

- synopsis: Perform a global search using a template with POST.
path: /_search/template
method: POST
request:
payload:
id: movie_template
params:
field:
value: year
value:
value: 2010
response:
status: 200

- synopsis: Perform a search using a template with GET (index-specific).
path: /{index}/_search/template
method: GET
parameters:
index: [movies]
request:
payload:
id: movie_template
params:
field:
value: director
value:
value: Quentin Tarantino
response:
status: 200

- synopsis: Perform a search using a template with POST (index-specific).
path: /{index}/_search/template
method: POST
parameters:
index: [movies]
request:
payload:
id: movie_template
params:
field:
value: title
value:
value: Inception
response:
status: 200
Loading