From 0ee21a86580b04eb31e27c28d2bdcec6c59be2a0 Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Wed, 4 Dec 2024 00:14:00 +0500 Subject: [PATCH] adding `rank_eval indices` API tests (#704) * adding rank_eval indices api specs Signed-off-by: Tokesh * lint for ci and verbose check early versions Signed-off-by: Tokesh * adding _type parameter to rank-eval specs Signed-off-by: Tokesh * fixing reference and adding changelog Signed-off-by: Tokesh * adding rank_eval global Signed-off-by: Tokesh * removing verbose flag from ci Signed-off-by: Tokesh * missing one link in changelog Signed-off-by: Tokesh --------- Signed-off-by: Tokesh Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- CHANGELOG.md | 4 +- spec/schemas/_core.rank_eval.yaml | 4 +- tests/default/_core/rank_eval.yaml | 62 ++++++++++++++++++++++++++ tests/default/indices/rank_eval.yaml | 66 ++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 tests/default/_core/rank_eval.yaml create mode 100644 tests/default/indices/rank_eval.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8785f7b7..39e98648 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 87268955..436d271e 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 00000000..65a609ba --- /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 00000000..b2e2791d --- /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