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

adding rank_eval indices API tests #704

Merged
merged 9 commits into from
Dec 3, 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion spec/schemas/_core.rank_eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ components:
additionalProperties:
type: object
additionalProperties:
type: object
type: number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these are always numbers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to read it in the future, most likely yes.
If I notice it's not, I'll open a new pull request.

required:
- hits
- metric_details
Expand Down Expand Up @@ -168,6 +168,8 @@ components:
$ref: '_common.yaml#/components/schemas/IndexName'
_score:
type: number
_type:
Tokesh marked this conversation as resolved.
Show resolved Hide resolved
$ref: '_common.yaml#/components/schemas/Type'
required:
- _id
- _index
Expand Down
62 changes: 62 additions & 0 deletions tests/default/_core/rank_eval.yaml
Original file line number Diff line number Diff line change
@@ -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
66 changes: 66 additions & 0 deletions tests/default/indices/rank_eval.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading