diff --git a/CHANGELOG.md b/CHANGELOG.md index 5854a451c..350c17fe3 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)) @@ -33,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 0b9a6f138..bd5afec8c 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: @@ -4000,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 @@ -4256,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 @@ -4352,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 @@ -4590,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 @@ -4705,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 @@ -4893,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 @@ -5237,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 @@ -6357,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/_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 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 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: 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 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 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