From 0b51d027cc59205a2f6245d8c0646dc079ae46e6 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 15 Dec 2024 23:10:56 +0500 Subject: [PATCH] added msearch template tests Signed-off-by: Tokesh --- CHANGELOG.md | 1 + spec/schemas/_core.msearch_template.yaml | 4 +- tests/default/indices/msearch_template.yaml | 51 +++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/default/indices/msearch_template.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6dc5979..45be9002a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/spec/schemas/_core.msearch_template.yaml b/spec/schemas/_core.msearch_template.yaml index f9e164e84..c87bbc3da 100644 --- a/spec/schemas/_core.msearch_template.yaml +++ b/spec/schemas/_core.msearch_template.yaml @@ -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 diff --git a/tests/default/indices/msearch_template.yaml b/tests/default/indices/msearch_template.yaml new file mode 100644 index 000000000..bb5631fee --- /dev/null +++ b/tests/default/indices/msearch_template.yaml @@ -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} + - {create: {_index: books, _id: book2}} + - {author: "Elizabeth Rudnick", title: "Beauty and the Beast", year: 1991} + - {create: {_index: books, _id: book3}} + - {author: "George Orwell", title: "1984", year: 1949} +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 \ No newline at end of file