From 0b51d027cc59205a2f6245d8c0646dc079ae46e6 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 15 Dec 2024 23:10:56 +0500 Subject: [PATCH 1/5] 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 From 54cd734f9c95a1b90a6f47fb236a36754c936b15 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 15 Dec 2024 23:13:18 +0500 Subject: [PATCH 2/5] lint fix Signed-off-by: Tokesh --- tests/default/indices/msearch_template.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/default/indices/msearch_template.yaml b/tests/default/indices/msearch_template.yaml index bb5631fee..163563e38 100644 --- a/tests/default/indices/msearch_template.yaml +++ b/tests/default/indices/msearch_template.yaml @@ -10,11 +10,11 @@ prologues: content_type: application/x-ndjson payload: - {create: {_index: books, _id: book1}} - - {author: "Harper Lee", title: "To Kill a Mockingbird", year: 1960} + - {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} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} - {create: {_index: books, _id: book3}} - - {author: "George Orwell", title: "1984", year: 1949} + - {author: George Orwell, title: '1984', year: 1949} epilogues: - path: /books method: DELETE @@ -30,9 +30,9 @@ chapters: content_type: application/x-ndjson payload: - {index: books} - - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: "Mockingbird"}} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Mockingbird}} - {index: books} - - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: "Beast"}} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}} response: status: 200 - synopsis: Perform a multi-search template query using a POST request. @@ -44,8 +44,8 @@ chapters: content_type: application/x-ndjson payload: - {index: books} - - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: "1984"}} + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: '1984'}} - {index: books} - - {source: '{"query": {"match": {"author": "{{author}}"}}}', params: {author: "Harper Lee"}} + - {source: '{"query": {"match": {"author": "{{author}}"}}}', params: {author: Harper Lee}} response: status: 200 \ No newline at end of file From 9d4b1b8eb7ecd1cdda25c3bf424b924b8bc535d3 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 16 Dec 2024 17:30:54 +0500 Subject: [PATCH 3/5] added core msearch template tests Signed-off-by: Tokesh --- tests/default/_core/msearch_template.yaml | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/default/_core/msearch_template.yaml diff --git a/tests/default/_core/msearch_template.yaml b/tests/default/_core/msearch_template.yaml new file mode 100644 index 000000000..31ca732fd --- /dev/null +++ b/tests/default/_core/msearch_template.yaml @@ -0,0 +1,47 @@ +$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: /_msearch/template + 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: /_msearch/template + 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 From b377b372922b706e0cf58412efc3f88f1b4b33e9 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 16 Dec 2024 17:42:26 +0500 Subject: [PATCH 4/5] added msearch get tests Signed-off-by: Tokesh --- tests/default/indices/msearch.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch.yaml index ba5cd97eb..361c5b898 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch.yaml @@ -21,6 +21,20 @@ epilogues: status: [200, 404] chapters: - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. + path: /{index}/_msearch + method: GET + parameters: + index: books + request: + content_type: application/x-ndjson + payload: + - {index: books} + - {query: {match: {title: To Kill a Mockingbird}}} + - {index: books} + - {query: {match: {title: The Cruise}}} + response: + status: 200 + - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call (POST). path: /{index}/_msearch method: POST parameters: From 7effb63f6558f33e002b10a3fff612457ed1b4cb Mon Sep 17 00:00:00 2001 From: Tokesh Date: Tue, 17 Dec 2024 19:11:45 +0500 Subject: [PATCH 5/5] renaming folders, using multiple methods, deleting default code Signed-off-by: Tokesh --- CHANGELOG.md | 2 +- .../{msearch.yaml => msearch/index.yaml} | 38 +++---------------- .../template.yaml} | 24 +++--------- .../{msearch.yaml => msearch/index.yaml} | 24 +++--------- .../template.yaml} | 26 +++---------- 5 files changed, 23 insertions(+), 91 deletions(-) rename tests/default/_core/{msearch.yaml => msearch/index.yaml} (61%) rename tests/default/_core/{msearch_template.yaml => msearch/template.yaml} (59%) rename tests/default/indices/{msearch.yaml => msearch/index.yaml} (63%) rename tests/default/indices/{msearch_template.yaml => msearch/template.yaml} (59%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c196f2807..47d9f9b01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added response schema for `PUT` and `DELETE /_plugins/_transform/{id}` ([#722](https://github.com/opensearch-project/opensearch-api-specification/pull/716)) - Added response schema for `GET /_plugins/_knn/warmup/{index}` ([#717](https://github.com/opensearch-project/opensearch-api-specification/pull/717)) - Added support for multiple test verbs ([#724](https://github.com/opensearch-project/opensearch-api-specification/pull/724)) -- Added string type in additionalProperties to `msearch template` ([#735](https://github.com/opensearch-project/opensearch-api-specification/pull/735)) ### 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)) @@ -70,6 +69,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed response schema for `/_render/template` and `/_render/template/{id}` ([#724](https://github.com/opensearch-project/opensearch-api-specification/pull/724)) - Fixed data stream schema numeric property types ([#725](https://github.com/opensearch-project/opensearch-api-specification/pull/725)) - Fixed snapshot status numeric property types ([#729](https://github.com/opensearch-project/opensearch-api-specification/pull/729)) +- Fixed type in `_msearch/template` ([#735](https://github.com/opensearch-project/opensearch-api-specification/pull/735)) ### Changed - Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683)) diff --git a/tests/default/_core/msearch.yaml b/tests/default/_core/msearch/index.yaml similarity index 61% rename from tests/default/_core/msearch.yaml rename to tests/default/_core/msearch/index.yaml index 6cff72802..7cb893404 100644 --- a/tests/default/_core/msearch.yaml +++ b/tests/default/_core/msearch/index.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml description: Test document multi-search. epilogues: @@ -25,7 +25,9 @@ prologues: chapters: - synopsis: Run multiple search requests in single request (GET). path: /_msearch - method: GET + method: + - GET + - POST request: content_type: application/x-ndjson payload: @@ -52,34 +54,4 @@ chapters: - _index: movies _id: movie1 - _index: movies - _id: movie2 - - synopsis: Run multiple search requests in single request (POST). - path: /_msearch - method: POST - request: - content_type: application/x-ndjson - payload: - - {index: movies} - - {query: {match_all: {}}} - - {index: books} - - {query: {match_all: {}}} - response: - status: 200 - payload: - responses: - - hits: - total: - value: 2 - relation: eq - hits: - - _index: movies - _id: movie1 - - _index: movies - _id: movie2 - - hits: - total: - value: 1 - relation: eq - hits: - - _index: books - _id: book1 + _id: movie2 \ No newline at end of file diff --git a/tests/default/_core/msearch_template.yaml b/tests/default/_core/msearch/template.yaml similarity index 59% rename from tests/default/_core/msearch_template.yaml rename to tests/default/_core/msearch/template.yaml index 31ca732fd..f1246f644 100644 --- a/tests/default/_core/msearch_template.yaml +++ b/tests/default/_core/msearch/template.yaml @@ -1,6 +1,6 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml -description: Test _termvectors and _msearch/template APIs. +description: Test _msearch/template APIs. prologues: - path: /_bulk method: POST @@ -23,25 +23,13 @@ epilogues: chapters: - synopsis: Perform a multi-search template query using a GET request. path: /_msearch/template - method: GET + method: + - GET + - POST 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: /_msearch/template - 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 + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}} \ No newline at end of file diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch/index.yaml similarity index 63% rename from tests/default/indices/msearch.yaml rename to tests/default/indices/msearch/index.yaml index 361c5b898..53fbb7122 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch/index.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations. prologues: @@ -22,7 +22,9 @@ epilogues: chapters: - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. path: /{index}/_msearch - method: GET + method: + - GET + - POST parameters: index: books request: @@ -31,20 +33,4 @@ chapters: - {index: books} - {query: {match: {title: To Kill a Mockingbird}}} - {index: books} - - {query: {match: {title: The Cruise}}} - response: - status: 200 - - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call (POST). - path: /{index}/_msearch - method: POST - parameters: - index: books - request: - content_type: application/x-ndjson - payload: - - {index: books} - - {query: {match: {title: To Kill a Mockingbird}}} - - {index: books} - - {query: {match: {title: The Cruise}}} - response: - status: 200 \ No newline at end of file + - {query: {match: {title: The Cruise}}} \ No newline at end of file diff --git a/tests/default/indices/msearch_template.yaml b/tests/default/indices/msearch/template.yaml similarity index 59% rename from tests/default/indices/msearch_template.yaml rename to tests/default/indices/msearch/template.yaml index 163563e38..0586dc449 100644 --- a/tests/default/indices/msearch_template.yaml +++ b/tests/default/indices/msearch/template.yaml @@ -1,6 +1,6 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml -description: Test _termvectors and _msearch/template APIs. +description: Test _msearch/template APIs. prologues: - path: /_bulk method: POST @@ -25,27 +25,13 @@ chapters: path: /{index}/_msearch/template parameters: index: books - method: GET + method: + - GET + - POST 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 + - {source: '{"query": {"match": {"title": "{{title}}"}}}', params: {title: Beast}} \ No newline at end of file