Skip to content

Commit

Permalink
added msearch template tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh committed Dec 15, 2024
1 parent 87847db commit 0b51d02
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added missing `status` to `/_search/template` response ([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702))
- Added `_type` to `rank_eval` API specs ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704))
- Added request body to `_search_shards` API specs ([#709](https://github.com/opensearch-project/opensearch-api-specification/pull/709))
- Added string type in additionalProperties to `msearch template` ([#x](https://github.com/opensearch-project/opensearch-api-specification/pull/x))

### 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
4 changes: 3 additions & 1 deletion spec/schemas/_core.msearch_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ components:
The value is the variable value.
type: object
additionalProperties:
type: object
oneOf:
- type: string
- type: object
profile:
description: When `true`, provides a profile for the query execution.
type: boolean
Expand Down
51 changes: 51 additions & 0 deletions tests/default/indices/msearch_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test _termvectors and _msearch/template APIs.
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: books, _id: book1}}
- {author: "Harper Lee", title: "To Kill a Mockingbird", year: 1960}

Check failure on line 13 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 13 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 13 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 13 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
- {create: {_index: books, _id: book2}}
- {author: "Elizabeth Rudnick", title: "Beauty and the Beast", year: 1991}

Check failure on line 15 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 15 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 15 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 15 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
- {create: {_index: books, _id: book3}}
- {author: "George Orwell", title: "1984", year: 1949}

Check failure on line 17 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 17 in tests/default/indices/msearch_template.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
epilogues:
- path: /books
method: DELETE
status: [200, 404]

chapters:
- synopsis: Perform a multi-search template query using a GET request.
path: /{index}/_msearch/template
parameters:
index: books
method: GET
request:
content_type: application/x-ndjson
payload:
- {index: books}
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: "Mockingbird"}}
- {index: books}
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: "Beast"}}
response:
status: 200
- synopsis: Perform a multi-search template query using a POST request.
path: /{index}/_msearch/template
parameters:
index: books
method: POST
request:
content_type: application/x-ndjson
payload:
- {index: books}
- {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: "1984"}}
- {index: books}
- {source: '{"query": {"match": {"author": "{{author}}"}}}', params: {author: "Harper Lee"}}
response:
status: 200

0 comments on commit 0b51d02

Please sign in to comment.