diff --git a/CHANGELOG.md b/CHANGELOG.md index 8785f7b74..39e986483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `s` to `/_ingest/processor/grok` ([#689](https://github.com/opensearch-project/opensearch-api-specification/pull/689)) - Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Added `aggregations` to `/nodes/_usage/{metric}` requests and responses ([#615](https://github.com/opensearch-project/opensearch-api-specification/pull/615)) -- Added missing `status` to `/_search/template` response([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702)) +- Added missing `status` to `/_search/template` response ([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702)) +- Added `_type` to `rank_eval` API specs ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704)) ### 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)) @@ -50,6 +51,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed `/_scripts/painless/_execute` request and response schema ([#699](https://github.com/opensearch-project/opensearch-api-specification/pull/699)) - Fixed `fields` in `Hit` allowing primitive arrays ([#699](https://github.com/opensearch-project/opensearch-api-specification/pull/699)) - Added missing `repository` query parameter to `/_cat/snapshots` ([#700](https://github.com/opensearch-project/opensearch-api-specification/pull/700)) +- Fixed `hits` in `rank_eval` allowing numbers ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704)) ### 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/schemas/_core.rank_eval.yaml b/spec/schemas/_core.rank_eval.yaml index 872689551..436d271ea 100644 --- a/spec/schemas/_core.rank_eval.yaml +++ b/spec/schemas/_core.rank_eval.yaml @@ -134,7 +134,7 @@ components: additionalProperties: type: object additionalProperties: - type: object + type: number required: - hits - metric_details @@ -168,6 +168,8 @@ components: $ref: '_common.yaml#/components/schemas/IndexName' _score: type: number + _type: + $ref: '_common.yaml#/components/schemas/Type' required: - _id - _index diff --git a/tests/default/_core/rank_eval.yaml b/tests/default/_core/rank_eval.yaml new file mode 100644 index 000000000..65a609bae --- /dev/null +++ b/tests/default/_core/rank_eval.yaml @@ -0,0 +1,62 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test rank evaluation API using both GET and POST methods. +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: Quentin Tarantino, title: Pulp Fiction, year: 1994} + - {create: {_index: movies, _id: movie2}} + - {director: Christopher Nolan, title: Inception, year: 2010} + +chapters: + - synopsis: Perform rank evaluation using GET. + path: /_rank_eval + method: GET + request: + payload: + metric: + precision: + k: 10 + requests: + - id: query_1 + request: + query: + match: + title: Pulp Fiction + ratings: + - _id: movie1 + rating: 1 + _index: movies + response: + status: 200 + + - synopsis: Perform rank evaluation using POST. + path: /_rank_eval + method: POST + request: + payload: + metric: + mean_reciprocal_rank: + k: 10 + requests: + - id: query_2 + request: + query: + match: + director: Christopher Nolan + ratings: + - _id: movie2 + _index: movies + rating: 1 + response: + status: 200 diff --git a/tests/default/indices/rank_eval.yaml b/tests/default/indices/rank_eval.yaml new file mode 100644 index 000000000..b2e2791d7 --- /dev/null +++ b/tests/default/indices/rank_eval.yaml @@ -0,0 +1,66 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test rank evaluation API using both GET and POST methods. +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: Quentin Tarantino, title: Pulp Fiction, year: 1994} + - {create: {_index: movies, _id: movie2}} + - {director: Christopher Nolan, title: Inception, year: 2010} + +chapters: + - synopsis: Perform rank evaluation using GET. + path: /{index}/_rank_eval + method: GET + parameters: + index: movies + request: + payload: + metric: + precision: + k: 10 + requests: + - id: query_1 + request: + query: + match: + title: Pulp Fiction + ratings: + - _id: movie1 + rating: 1 + _index: movies + response: + status: 200 + + - synopsis: Perform rank evaluation using POST. + path: /{index}/_rank_eval + method: POST + parameters: + index: [movies] + request: + payload: + metric: + mean_reciprocal_rank: + k: 10 + requests: + - id: query_2 + request: + query: + match: + director: Christopher Nolan + ratings: + - _id: movie2 + _index: movies + rating: 1 + response: + status: 200