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

More tests, fixes ExplanationDetail/value. #685

Merged
merged 3 commits into from
Nov 20, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- 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))
- Fixed `value` type in `ExplanationDetail` and added `_type` to `explain@200` ([#685](https://github.com/opensearch-project/opensearch-api-specification/pull/685))

### 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))
Expand Down
2 changes: 2 additions & 0 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,8 @@ components:
schema:
type: object
properties:
_type:
$ref: '../schemas/_common.yaml#/components/schemas/Type'
_index:
$ref: '../schemas/_common.yaml#/components/schemas/IndexName'
_id:
Expand Down
2 changes: 1 addition & 1 deletion spec/schemas/_core.explain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ components:
items:
$ref: '#/components/schemas/ExplanationDetail'
value:
oneOf:
anyOf:
- type: integer
format: int32
- type: integer
Expand Down
25 changes: 25 additions & 0 deletions tests/default/indices/block.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test limiting certain operations on a specified index.
prologues:
- path: /movies
method: PUT
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Disable any write operations made to the index.
path: /{index}/_block/{block}
method: PUT
parameters:
index: movies
block: write
response:
status: 200
payload:
shards_acknowledged: true
acknowledged: true
indices:
- name: movies
blocked: true
4 changes: 2 additions & 2 deletions tests/default/indices/clone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ chapters:
- synopsis: Clone an index (wait_for_completion).
version: '>= 2.7'
path: /{index}/_clone/{target}
method: POST
method: PUT
parameters:
index: movies
target: games2
Expand All @@ -51,7 +51,7 @@ chapters:
- synopsis: Clone an index (cluster_manager_timeout).
version: '>= 2.0'
path: /{index}/_clone/{target}
method: POST
method: PUT
parameters:
index: movies
target: games3
Expand Down
51 changes: 51 additions & 0 deletions tests/default/indices/explain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test getting an explanation of how the relevance score is calculated for every result.
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: Bennett Miller, title: The Cruise, year: 1998}
- {create: {_index: movies, _id: movie2}}
- {director: Nicolas Winding Refn, title: Drive, year: 1960}
chapters:
- synopsis: Explain the score for a match query (GET).
path: /{index}/_explain/{id}
method: GET
parameters:
index: movies
id: movie1
request:
payload:
query:
match:
year: 1998
response:
status: 200
- synopsis: Explain the score for a match query (POST).
path: /{index}/_explain/{id}
method: POST
parameters:
index: movies
id: movie2
preference: _local
routing: primary
_source: true
_source_excludes: title
_source_includes: director
request:
payload:
query:
match:
title: Drive
response:
status: 200
Loading