From 05288102dcec75c6ff72a2616483c67dd91de1e6 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 Nov 2024 14:23:40 -0500 Subject: [PATCH 1/6] Added test for GET /{index}/_refresh. Signed-off-by: dblock --- tests/default/indices/refresh.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/default/indices/refresh.yaml b/tests/default/indices/refresh.yaml index eb8f69057..a17644e53 100644 --- a/tests/default/indices/refresh.yaml +++ b/tests/default/indices/refresh.yaml @@ -14,7 +14,17 @@ prologues: year: 1991 status: [201] chapters: - - synopsis: Refresh an index. + - synopsis: Refresh an index (GET). + path: /{index}/_refresh + method: GET + parameters: + index: movies + response: + status: 200 + payload: + _shards: + failed: 0 + - synopsis: Refresh an index (POST). path: /{index}/_refresh method: POST parameters: From d102f52593ae458c88c2c26e9bd435bebae49769 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 Nov 2024 14:31:01 -0500 Subject: [PATCH 2/6] Added and returning . Signed-off-by: dblock --- CHANGELOG.md | 1 + spec/namespaces/_core.yaml | 12 +++++++ tests/default/indices/source.yaml | 52 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 tests/default/indices/source.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 045729721..faf070732 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `/_cluster/stats/{metric}/nodes/{node_id}` and `/_cluster/stats/{metric}/{index_metric}/nodes/{node_id}` ([#639](https://github.com/opensearch-project/opensearch-api-specification/pull/639)) - Added `PhoneAnalyzer` from `analysis-phonenumber` plugin ([#609](https://github.com/opensearch-project/opensearch-api-specification/pull/609)) - Added `/_list/indices` & `/_list/shards` api specs ([#613](https://github.com/opensearch-project/opensearch-api-specification/pull/613)) +- Added `GET` and `HEAD /{index}/_source/{id}` returning `404` ([#673](https://github.com/opensearch-project/opensearch-api-specification/pull/673)) ### 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/namespaces/_core.yaml b/spec/namespaces/_core.yaml index 0b9a6f138..fd9aa1133 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -2047,6 +2047,8 @@ paths: responses: '200': $ref: '#/components/responses/get_source@200' + '404': + $ref: '#/components/responses/get_source@404' head: operationId: exists_source.0 x-operation-group: exists_source @@ -2069,6 +2071,8 @@ paths: responses: '200': $ref: '#/components/responses/exists_source@200' + '404': + $ref: '#/components/responses/exists_source@404' /{index}/_termvectors: get: operationId: termvectors.0 @@ -2913,6 +2917,9 @@ components: exists_source@200: content: application/json: {} + exists_source@404: + content: + application/json: {} explain@200: content: application/json: @@ -3019,6 +3026,11 @@ components: application/json: schema: type: object + get_source@404: + content: + application/json: + schema: + $ref: '../schemas/query._common.yaml#/components/schemas/ErrorResponse' index@200: content: application/json: diff --git a/tests/default/indices/source.yaml b/tests/default/indices/source.yaml new file mode 100644 index 000000000..4d7c234c2 --- /dev/null +++ b/tests/default/indices/source.yaml @@ -0,0 +1,52 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test retrieving a document source. +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /movies/_doc/1 + method: POST + parameters: + refresh: true + request: + payload: + title: Beauty and the Beast + year: 1991 +chapters: + - synopsis: Retrieve the document source. + path: /{index}/_source/{id} + method: GET + parameters: + index: movies + id: '1' + response: + status: 200 + payload: + title: Beauty and the Beast + year: 1991 + - synopsis: Retrieve a non-existent document source. + path: /{index}/_source/{id} + method: GET + parameters: + index: movies + id: '2' + response: + status: 404 + - synopsis: Check whether the document exists. + path: /{index}/_source/{id} + method: HEAD + parameters: + index: movies + id: '1' + response: + status: 200 + - synopsis: Check whether the document exists. + path: /{index}/_source/{id} + method: HEAD + parameters: + index: movies + id: '2' + response: + status: 404 From 4f479ac180496716543f791429158870e51d5195 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 Nov 2024 14:34:01 -0500 Subject: [PATCH 3/6] Added tests for POST /{index}/_mget. Signed-off-by: dblock --- tests/default/indices/mget.yaml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/default/indices/mget.yaml b/tests/default/indices/mget.yaml index 9b81f3dd8..07732a33c 100644 --- a/tests/default/indices/mget.yaml +++ b/tests/default/indices/mget.yaml @@ -18,7 +18,7 @@ prologues: - {create: {_index: movies, _id: movie2}} - {director: Nicolas Winding Refn, title: Drive, year: 1960} chapters: - - synopsis: Retrieve documents from multiple indexes. + - synopsis: Retrieve documents from multiple indexes (GET). path: /{index}/_mget method: GET parameters: @@ -46,3 +46,21 @@ chapters: _id: movie1 - _index: movies _id: movie2 + - synopsis: Retrieve documents from multiple indexes (POST). + path: /{index}/_mget + method: POST + parameters: + index: movies + request: + payload: + docs: + - _id: movie1 + - _id: movie2 + response: + status: 200 + payload: + docs: + - _index: movies + _id: movie1 + - _index: movies + _id: movie2 From 8903287e6173267bc459b6532351922ba271669e Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 Nov 2024 14:53:54 -0500 Subject: [PATCH 4/6] Fixed all refresh options to allow boolean and string. Signed-off-by: dblock --- CHANGELOG.md | 1 + spec/namespaces/_core.yaml | 16 +++--- spec/schemas/_common.yaml | 12 +++-- tests/default/indices/update.yaml | 82 +++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 tests/default/indices/update.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index faf070732..aad2f6bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Fixed `/{index}/_create/{id}` returning `201` ([#669](https://github.com/opensearch-project/opensearch-api-specification/pull/669)) - Fixed `ml._common.yaml#SearchModelsResponse` and `SearchModelsHitsHit` ([#672](https://github.com/opensearch-project/opensearch-api-specification/pull/672)) +- Fixed `refresh` options to allow `boolean` and `string` ([#673](https://github.com/opensearch-project/opensearch-api-specification/pull/673)) ## [0.1.0] - 2024-10-25 diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index fd9aa1133..bd5afec8c 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -4012,7 +4012,7 @@ components: name: refresh description: If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form delete_by_query::query.request_cache: in: query @@ -4268,7 +4268,7 @@ components: name: refresh description: If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form exists::query.routing: in: query @@ -4364,7 +4364,7 @@ components: name: refresh description: If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form exists_source::query.routing: in: query @@ -4602,7 +4602,7 @@ components: name: refresh description: If true, OpenSearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form get::query.routing: in: query @@ -4717,7 +4717,7 @@ components: name: refresh description: If true, OpenSearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form get_source::query.routing: in: query @@ -4905,7 +4905,7 @@ components: name: refresh description: If `true`, the request refreshes relevant shards before retrieving documents. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form mget::query.routing: in: query @@ -5249,7 +5249,7 @@ components: name: refresh description: If `true`, the request refreshes affected shards to make this operation visible to search. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form reindex::query.requests_per_second: in: query @@ -6369,7 +6369,7 @@ components: name: refresh description: If `true`, OpenSearch refreshes affected shards to make the operation visible to search. schema: - type: boolean + $ref: '../schemas/_common.yaml#/components/schemas/Refresh' style: form update_by_query::query.request_cache: in: query diff --git a/spec/schemas/_common.yaml b/spec/schemas/_common.yaml index 5ef209d8a..229bdc970 100644 --- a/spec/schemas/_common.yaml +++ b/spec/schemas/_common.yaml @@ -767,11 +767,13 @@ components: NodeName: type: string Refresh: - type: string - enum: - - 'false' - - 'true' - - wait_for + oneOf: + - type: boolean + - type: string + enum: + - 'false' + - 'true' + - wait_for WaitForActiveShards: oneOf: - title: count diff --git a/tests/default/indices/update.yaml b/tests/default/indices/update.yaml new file mode 100644 index 000000000..bbe553fd7 --- /dev/null +++ b/tests/default/indices/update.yaml @@ -0,0 +1,82 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test updating a document. +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /movies/_doc/1 + method: POST + parameters: + refresh: true + request: + payload: + title: Beauty and the Beast + year: 1990 +chapters: + - synopsis: Update a document in the index. + path: /{index}/_update/{id} + method: POST + parameters: + index: movies + id: '1' + refresh: true + request: + payload: + doc: + title: Beauty and the Beast + year: 1991 + response: + status: 200 + payload: + result: updated + - synopsis: Update a document in the index using a script. + path: /{index}/_update/{id} + method: POST + parameters: + index: movies + id: '1' + request: + payload: + script: + source: ctx._source.year += params.value + lang: painless + params: + value: 10 + response: + status: 200 + payload: + result: updated + - synopsis: Upsert a document. + path: /{index}/_update/{id} + method: POST + parameters: + index: movies + id: '1' + request: + payload: + doc: + title: Drive + upsert: + title: Drive + response: + status: 200 + payload: + result: updated + - synopsis: Upsert a document (doc_as_upsert). + path: /{index}/_update/{id} + method: POST + parameters: + index: movies + id: '1' + request: + payload: + doc: + title: Drive + year: 2011 + doc_as_upsert: true + response: + status: 200 + payload: + result: updated From dd5aba3daf0b0d5f0ee578cb41edad4d9ae17931 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 Nov 2024 14:56:48 -0500 Subject: [PATCH 5/6] Added tests for POST /_msearch. Signed-off-by: dblock --- tests/default/_core/msearch.yaml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/default/_core/msearch.yaml b/tests/default/_core/msearch.yaml index 79d92c9b8..6cff72802 100644 --- a/tests/default/_core/msearch.yaml +++ b/tests/default/_core/msearch.yaml @@ -23,7 +23,7 @@ prologues: - {create: {_index: movies, _id: movie2}} - {director: Nicolas Winding Refn, title: Drive, year: 1960} chapters: - - synopsis: Run multiple search requests in single request. + - synopsis: Run multiple search requests in single request (GET). path: /_msearch method: GET request: @@ -53,3 +53,33 @@ chapters: _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 From 0c8b3b87067a29c5324faa6b5ac79589c61d34ea Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 Nov 2024 14:59:19 -0500 Subject: [PATCH 6/6] Added tests for PUT /_bulk/stream. Signed-off-by: dblock --- tests/plugins/streaming/_core/bulk/stream.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/plugins/streaming/_core/bulk/stream.yaml b/tests/plugins/streaming/_core/bulk/stream.yaml index 7560ea715..a35c98f05 100644 --- a/tests/plugins/streaming/_core/bulk/stream.yaml +++ b/tests/plugins/streaming/_core/bulk/stream.yaml @@ -15,6 +15,15 @@ chapters: payload: - {create: {_index: movies}} - {director: Bennett Miller, title: Moneyball, year: 2011} + - synopsis: Update an index. + version: '>= 2.17' + path: /_bulk/stream + method: PUT + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies}} + - {director: Bennett Miller, title: Drive, year: 2011} - synopsis: Delete document in an index. version: '2.17' path: /_bulk/stream