From c34aaec367b3404c7173225ab481b79e2d21d454 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 1 Dec 2024 13:35:44 +0500 Subject: [PATCH 1/4] adding tests for search templates Signed-off-by: Tokesh --- spec/namespaces/_core.yaml | 2 + tests/default/indices/template.yaml | 95 +++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/default/indices/template.yaml diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index 8149f7cf4..6b032fc2f 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -3266,6 +3266,8 @@ components: $ref: '../schemas/_core.search.yaml#/components/schemas/Suggest' terminated_early: type: boolean + status: + type: number required: - _shards - hits diff --git a/tests/default/indices/template.yaml b/tests/default/indices/template.yaml new file mode 100644 index 000000000..a4da97080 --- /dev/null +++ b/tests/default/indices/template.yaml @@ -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 \ No newline at end of file From 2e6464a96093d424c9f0fb075ab176734d8d35fc Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 2 Dec 2024 21:35:08 +0500 Subject: [PATCH 2/4] adding changelog log Signed-off-by: Tokesh --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4d4d0a33..bb1e1d782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) From 0778647b5c49f5f44f355f7f43d1b5ef69863ebd Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 2 Dec 2024 22:19:01 +0500 Subject: [PATCH 3/4] renamed and moved to another more specific folders Signed-off-by: Tokesh --- .../indices/{ => search}/template.yaml | 28 --------- tests/default/search/template.yaml | 63 +++++++++++++++++++ 2 files changed, 63 insertions(+), 28 deletions(-) rename tests/default/indices/{ => search}/template.yaml (74%) create mode 100644 tests/default/search/template.yaml diff --git a/tests/default/indices/template.yaml b/tests/default/indices/search/template.yaml similarity index 74% rename from tests/default/indices/template.yaml rename to tests/default/indices/search/template.yaml index a4da97080..c9308995b 100644 --- a/tests/default/indices/template.yaml +++ b/tests/default/indices/search/template.yaml @@ -34,34 +34,6 @@ prologues: } 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 diff --git a/tests/default/search/template.yaml b/tests/default/search/template.yaml new file mode 100644 index 000000000..956f6fbd9 --- /dev/null +++ b/tests/default/search/template.yaml @@ -0,0 +1,63 @@ +$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 \ No newline at end of file From c8f5b15cd52eb4ad7f4bb5531e3d87ff6a4a39aa Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 2 Dec 2024 22:46:13 +0500 Subject: [PATCH 4/4] not correct path to root test story Signed-off-by: Tokesh --- tests/default/indices/search/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/default/indices/search/template.yaml b/tests/default/indices/search/template.yaml index c9308995b..879b73386 100644 --- a/tests/default/indices/search/template.yaml +++ b/tests/default/indices/search/template.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$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: