From a428c1c08bd1f28bf4a4b41ed6a9075873d73fa5 Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 20 Nov 2024 13:36:16 -0500 Subject: [PATCH] Added tests for GET and POST /{index}/_explain/{id}. Signed-off-by: dblock --- CHANGELOG.md | 3 +- spec/namespaces/_core.yaml | 2 ++ spec/schemas/_core.explain.yaml | 2 +- tests/default/indices/explain.yaml | 51 ++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/default/indices/explain.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 880c8a949..9a4e71137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,8 @@ 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` ([#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)) diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index 569b69b11..52a0056fd 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -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: diff --git a/spec/schemas/_core.explain.yaml b/spec/schemas/_core.explain.yaml index 5a3838a09..e7acc514b 100644 --- a/spec/schemas/_core.explain.yaml +++ b/spec/schemas/_core.explain.yaml @@ -39,7 +39,7 @@ components: items: $ref: '#/components/schemas/ExplanationDetail' value: - oneOf: + anyOf: - type: integer format: int32 - type: integer diff --git a/tests/default/indices/explain.yaml b/tests/default/indices/explain.yaml new file mode 100644 index 000000000..a99cc3561 --- /dev/null +++ b/tests/default/indices/explain.yaml @@ -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