Skip to content

Commit

Permalink
Added tests for GET and POST /{index}/_explain/{id}.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 20, 2024
1 parent da003f3 commit 76d124d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
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
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

0 comments on commit 76d124d

Please sign in to comment.