Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes and tests. #673

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

Expand Down
28 changes: 20 additions & 8 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -2913,6 +2917,9 @@ components:
exists_source@200:
content:
application/json: {}
exists_source@404:
content:
application/json: {}
explain@200:
content:
application/json:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 31 additions & 1 deletion tests/default/_core/msearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
20 changes: 19 additions & 1 deletion tests/default/indices/mget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
12 changes: 11 additions & 1 deletion tests/default/indices/refresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
52 changes: 52 additions & 0 deletions tests/default/indices/source.yaml
Original file line number Diff line number Diff line change
@@ -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
82 changes: 82 additions & 0 deletions tests/default/indices/update.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/plugins/streaming/_core/bulk/stream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading